Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
L_VN
Partner - Contributor III
Partner - Contributor III

Dollar expansion not working

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?

Labels (1)
4 Replies
Kushal_Chawda
MVP
MVP

@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))
PaulVerkooijen_DataFix
Partner - Specialist II
Partner - Specialist II

@L_VN 


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

p_verkooijen_1-1727434947797.png

 

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

  • Count({<FactsType = {'Open'}, From= {">=$(vMaxDate)-50"}, Date = {"$(vMaxDate)"}>} DISTINCT ID)


Please provide an output sample / formatting of

  • vMaxDate
  • From
  • Date

 

L_VN
Partner - Contributor III
Partner - Contributor III
Author

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"}

 

 

L_VN_0-1727679836315.png

Edit: I moved the parenthesis to include the calculation

 

marcus_sommer
MVP
MVP

I would probably do:

From= {">=$(=vMaxDate-50)"}