Hello team. Is it possible to create an MAQL metr...
# gd-beginners
a
Hello team. Is it possible to create an MAQL metric that shows a date attribute?
f
Hi Adair, depends on what you’re looking for! In GoodData Platform, it’s possible to use Date Attribute Arithmetics to calculate event durations, for example. You are also able to Find Min and Max Dates - meaning the earliest and latest dates some event occurred. Note that you may have to format the results so that they appear in a Date format, as the result will be displayed as an unformatted number, by default. The second article I posted explains how that can be achieved. If you’re looking to simply display dates with no calculation attached, you can simply add them to one of the Row or Column sections in the analytical designer - thus slicing your other metrics by them.
👏🏾 1
a
Well, I managed myself to turn a date attribute into a metric, but that only works if I put it in a table with some attribute column and I'd like to show it as a KPI on a dashboard. I'm obviously not an expert, but taking in consideration the GD documentation I'm afraid that's not possible.
f
Hi Adair, that really depends on what the metric calculates; Using a Headline insight, it’s definitely possible to display a date (see my screenshot), but it’s generally limited to MAX or MIN Date metrics - for example, showing the most recent transaction for a client. Then the dashboard filters would further refine it.
👍🏾 1
a
I finally made it, the date is now a metric but I'm trying another approach to display the metric in date format, but with no succes so far. I'm formatting the number right in the number formatting editor and the closest I've got so far was this: {{{|30|00}}}\/{{{1|12|00}}}\/{{{365||0000}}} It's not working, like the attached print shows. I need to display the number in DD/MM/YYY format.
Well, I just realize that formatting in the editor won't work, since months don't always have 30 days.
Would you @Francisco Antunes mind to share the metric you created so I could use it as a reference?
f
Hi @Adair Júnior, sorry for the delay here! I was out for a couple of weeks. My metric for showing the date is:
Copy code
SELECT (SELECT (10000 * MAX(Day of Month (Date))) + (100 * MAX(Month (Date))) + (MAX (Year (Date)) - 101)) BY Customer Id
the
-101
on the MAX Year is there because the numerical values for the Years after 2000 are represented by the numbers 101 to 151. Then, I formatted it like so:
Copy code
[=-101]N/A;
 0#/##/##
If the total value is
-101
, this means that the result was null/zero (so only the subtraction in the equation shows up). Otherwise, it displays them with slashes
/
- with a possible 0 in case the day is in the single digits. I hope that this is still helpful, even with the delay 🙂