Hello, I have a question about MAQL. Is the MAQL s...
# gooddata-platform
g
Hello, I have a question about MAQL. Is the MAQL syntax able to check the past date? Example: I have a date of 27/06/2021 then I want to check whether the date has passed 3 days or not.
z
Hi Giri, depends how exactly the metric is going to be used and with what kind of context. But in general you can create metric like this:
Copy code
SELECT IF (select count (Date (Ticket Created)) WHERE Date (Ticket Created)=THIS-3)=1 THEN 1 ELSE 0 END
Which takes Today date minus 3 days and then it is wrapped in IF condition to get also the other dates but these will be zeroes, only 3 days back is 1. This can be also changed to display YES or NO, e.g. by using metric formatting. e.g.
Copy code
[=0]NO;
[=1]YES;
Would that fit the use case?
g
Hello, I'm trying to count the number of dates 3 days ago with a formula like this:
select count(To Number) where Date (Release Date) = THIS - 3
Result: No Values ​​to Display Is there something wrong with the formula I'm using? Thank you
z
What is "To Number" column? It seems like there are simply no data inside of the column. you might actually want to count days passed instead, so try SELECT COUNT(Date (Release Date)) = THIS- 3
g
Yes I want to count the number of days that have passed. I tried using the formula
Copy code
SELECT count(Date(Release Date)) = THIS- 3
But an error message appears like this:
z
SELECT COUNT(Date (Release Date)) WHERE Date (Release Date) = THIS- 3
sorry about that, a part of my syntax was removed, this should work hopefully
g
Thanks, the syntax works fine. But there's something I want to ask again. I have data like the following:
My Data.png
Good Data.png
There are 5 rows of data on 21/06/2021 but the result of the script only counts 1 row. Thanks
z
@Giri Purnama I see, do you have some primary key set on the table? You will need to count the primary key and add it to your measure. But if you load your data via CSV for example, you will want to look for attribute called "records of <name of csv file/dataset>" and create measure SELECT COUNT(records of <name of csv file/dataset). does it make sense?
g
I use csv files. Can I ask for help to be guided step by step? Thank you.