Hopefully I'm just missing something stupid, but i...
# suiteanalytics
r
Hopefully I'm just missing something stupid, but in a SA workbook, is there seriously not a simple way to just do {trandate}>(date)? I've tried YYYY-MM-DD format, MM/DD/YYYY format, enclosing both in single quotes, in double quotes, in no quotes, in pound signs, in nothing, etc. I get a type mismatch every time. This website uses extracts and I got the below to work, but it's a ridiculously complex formula for what it's accomplishing, which is to just do something on a date greater than 6/9/2022. Anyone know a better way?
case when
extract(year from {trandate})>=2022 then (case when extract(month from {trandate})>=6 then (case when (extract(month from {trandate})=6 and extract(day from {trandate})>=9) or (extract(month from {trandate})>6 and extract(day from {trandate})>=1) then 0 else 1 end) else 1 end) else 1 end
p
Hi! Would this syntax work in your case? Where exactly are you trying to apply this condition?
{trandate}>TO_DATE('2022-06-09')
r
That worked, thank you! Might have been overthinking it. I believe in saved searches you don't need the to_date part, so I just assume SA workbooks might be the same. Thanks again
👍 1
Quirky little bug @Petr MalĂ˝ if you're interested since you're the product manager. SA Workbooks don't seem to like using the TO_DATE formula without the format clause....but only sometimes. It is ok with this:
case
when {transactionlines.custcol_xx_xxx_item^item.itemid} is null
then -{transactionlines.costestimate}
else -round((1-(case when {trandate}>=TO_DATE('2022-06-09','YYYY-MM-DD') then .035 else .0375 end))*{transactionlines.foreignamount},2)
end
But sometimes not this for some reason:
case
when {transactionlines.custcol_xx_xxx_item^item.itemid} is null
then -{transactionlines.costestimate}
else -round((1-(case when {trandate}>=TO_DATE('2022-06-09') then .035 else .0375 end))*{transactionlines.foreignamount},2)
end
The numbers in the sheet themselves calculate successfully without error in both cases and the formula validates successfully in both cases. But not putting the 'YYYY-MM-DD' causes the dataset to fail export to CSV. No error message, just nothing happens. Add in the 'YYYY-MM-DD' to the TO_DATE formula and then it will export again as expected. Oddly enough, I have another data set where I'm not using the 'YYYY-MM-DD' and it works and exports totally fine, so I have no idea what's going on. 🤷‍♂️
p
Hey @RJMNS! Thank you for bringing this up. Based on your description, it really looks like a true mystery 🙂 So I understand that the only problem is the export which worked for one dataset but didn't work for the other without specifying the format clause. Since there were no errors thrown, how did you recognize that the problem was caused by missing format clause? Or any chance that there is some error in the console of your browser, that would point to this? Please let me know, I am wondering what is going on there ablobthinking
r
how did you recognize that the problem was caused by missing format clause
A lot of painful trial and error and by process of elimination. I had about a dozen formula fields and so I added them to the data set one by one until I found one that caused it to stop exporting. Then I started swapping out pieces of the formula (multi-level Case statement) until I isolated it to the fact that the export worked with the TO_DATE field removed, but not when it was put back. Noticed in the notes for the TO_DATE field within SA it was supposed to have a format clause like that. So tried adding that in and it exported again. Removed it and the export stopped working. Could be something in the browser I suppose, but the one data set that was working that was missing that clause was run in the same browser. When I first noticed the issue in the other data set, I rebuilt it from scratch, thinking it had gotten corrupted somehow. The problem occurred in the new data set once I added the formula field with the TO_DATE formula. I'm not sure how to isolate which it is (browser or SA), I just know that one works and one didn't using essentially the same formula and the same browser. Super odd.
You piqued my curiosity @Petr MalĂ˝. Went and tried it in a different browser (Safari). Wouldn't export just like in the original browser I was using (Chrome). Fixed the 5-6 instances of this formula by adding in the format clause to each of the formula fields where it was used. Saved the Data Set. It then exported successfully in both browsers.
p
Got it and much appreciate the time you invested into investigation! In my opinion, it is always better to provide format clause and it is my mistake that I didn't include it in the original reply as if it is not provided, you rely on the default format set on the DB level which I don't know how that looks like for your DB. So if everything works with format provided, let's go with that. The strange behavior you described might have been caused by some caching for example and it will not be easy to figure this out, so unless it is blocking you somehow, I would say we a solution we can go with. But of course let me know if you see any issue with that or if encounter any other, I'll be happy to help.