Hi Team, Is there a way I can check the current da...
# gd-beginners
s
Hi Team, Is there a way I can check the current date in writing a custom metric
i
Hi Sree Lakshmi, I assume that you are working with GoodData Platform, but please correct me if I am wrong here. Are you familiar with THIS macro, please? Would it suit your use-case, by chance?
s
Hi Ivana, Thank you for responding.. Yes, I am working with GoodData Platform...
In one of my queries I need to check if the current date is less than 4 or not..
This is failing If THIS < 4
While I am aware of THIS macro I am not able to use it for this specific use case ..
i
Sure thing, happy to help. I am afraid that your MAQL expression would need to be more complex. May I know what exactly are you trying to achieve, please? Should it include all dates before the 4th day of the current month or week, for e.g.?
s
Thank you! What I need is, if the current date is < 4th I need to pull the revenue from the 4th of previous month till today.. If the current date is > 4th I need to pull the revenue from the 4th of current month till today
i
Thank you for the clarification. Let me think about the proper condition a bit.
How would you check the current date, please? Would it be picked from the Dashboard Date filter, or are we searching for MAX Date, where’s available value?
s
Ideally it should be from Max Date, since dashboard wont give any info specifically about the current date
✔️ 1
i
Hey @SreeLakshmi Mukalla, Sorry for the radio silence here. I was thinking about something similar to my metric below:
SELECT CASE WHEN (MAX (Day of Month (Date))<=4) THEN (SELECT Revenue WHERE Day of Month (Date) BETWEEN 1 AND 4) ELSE (SELECT Revenue FOR PREVIOUS (Month/Year (Date)) WHERE Day of Month (Date) BETWEEN 5 AND 31) END
However, I’d like to see your existing Revenue metric and your model as well, if possible. Could you kindly share with me a link to your testing Insight or the details about your workspace, please? Feel free to use a DM, as I understand you might not want to share these details publicly.