Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to calculate a measure where I count the numbers if ID that have been open for at least 50 days in any given period.
I have a facts table where each ID has a FactsType = 'Open'. This is linked to the Calendar for all days from Start to Close - 1. This means that I want to calculate the number of distinct ID which are linked to the calendar on the Max(Date), who have a FactsType = 'Open' and where Max(Date) - From > 50.
I have a variable for Max(Date) called vMaxDate.
My expression looks like:
Count(DISTINCT
Aggr(
If("=$(vMaxDate)" - From > 50, ID),
ID
)
{<FactsType = {'Open'}, Date = {"=$(vMaxDate)"}>}
)
But the dollar expansions do not work for whatever reason.
Could someone help me?
@L_VN try below
Count(DISTINCT {<FactsType = {'Open'},ID = {"=$(vMaxDate)-From >50"}>} ID)
or
Count(DISTINCT {<FactsType = {'Open'}>}aggr(if($(vMaxDate)-From >50,ID),ID))
How is the variable vMaxDate defined?
Does it contain a result, for instance: =DATE(Today(), 'M/D/YYYY') then the output = 9/27/2024
or only the base formula without starting with = the output would be : DATE(Today(), 'M/D/YYYY')
Based on the result of the variable the first usage of the variable could not need an dollar sign expansion. When you use $(vMaxDate) on the result 9/27/2024 it will calculate 1,6469038208169
Also the use of "" for the IF is incorrect, you only need it in the Set Analysis
Count(DISTINCT
Aggr(
If($(vMaxDate) - From > 50, ID),
ID
)
{<FactsType = {'Open'}, Date = {"=$(vMaxDate)"}>}
)
Besides that the complete expression seems incorrect.
This should work
Please provide an output sample / formatting of
Oh, I never knew that the equals sign made a difference.
All three are floored ints, so it should work. I don't think this works. Qlik seems to interpret it as the string value (see my attached image).
From= {">=$(vMaxDate)-50"}
Edit: I moved the parenthesis to include the calculation
I would probably do:
From= {">=$(=vMaxDate-50)"}