Select to view content in your preferred language

Dashboard - Today Date Unless data is blank

2514
16
10-20-2021 12:38 PM
RickeyFight
MVP Regular Contributor

I am looking for help with a script to display only todays data unless todays data has not been displayed yet. If that is the case display yesterday data. 

I am thinking it would be if today > 0 display today data if not display today-1

 

 

16 Replies
jcarlson
MVP Esteemed Contributor

Always tricky to debug to without having access to the data. Glad you got it working!

- Josh Carlson
Kendall County GIS
RickeyFight
MVP Regular Contributor

@jcarlson 

I got it to work once.  When I test I get the results I want but the script picker now gives me this error

RickeyFight_0-1634918876958.png

 

0 Kudos
RickeyFight
MVP Regular Contributor

@jcarlson 

 

 

// Filter records with empty values (future dates)
var filt = Filter(fs, "REEDER_Percent_FULL IS NOT NULL REEDER_Percent_FULL <> ''")
 
// Sort filtered records for most recent first
var sorted = OrderBy(fs, "Date_ DESC")

// Return top record
return First(sorted)

 

This is what I have so far. 

 

I am getting this error:

Execution Error:Expected "*", "+", "-", "/", "AND", "OR", [ \t\n\r], or end of input but "R" found. 

jcarlson
MVP Esteemed Contributor

You need an "AND" before the second statement in your SQL.

"...IS NOT NULL AND REEDER_Percent_FULL..."

EDIT: Change that to AND.

- Josh Carlson
Kendall County GIS
0 Kudos
RickeyFight
MVP Regular Contributor

@jcarlson 

I am now getting data to display but it is still showing the Null data. How does the var filt apply to the sorted layer? 

RickeyFight_0-1634847565700.png

 

0 Kudos
jcarlson
MVP Esteemed Contributor

I edited my reply below, but I think we want an "AND" in the SQL statement, not "OR". Something that has a value of '', that is, an empty string, will still satisfy the "IS NOT NULL" condition, allowing it through. My mistake!

- Josh Carlson
Kendall County GIS
0 Kudos
RickeyFight
MVP Regular Contributor

@jcarlson 

Thank you for your continued help on this.

I am not sure the "AND" is the issue. I added the change and this is what I get. I think the problem is that the "filt" var is defined but then not put into the result. I would think that the "sorted" var would need to reference the "filt" var at some point. 

 

RickeyFight_0-1634914484041.png

 

0 Kudos