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: 
aisolomatin
Contributor III
Contributor III

Dynamic variable & previous date value

Greetings!

I'm trying to get previous date value via set analysis in straight table.

I get expression/variable for previous date (column 5):

 

v_prev_m =if(Dimensionality()=0,
       
Date(MonthEnd(AddMonths(Min(CurDate),-1))),
       
Date(MonthEnd(AddMonths(CurDate,-1))))

 

Expression for previous month value (column4):

 

=Sum(
       
Aggr(
             
Sum({<CurDate={"$(=v_prev_m)"}>}Fact),
             
Territory))

 

Everything works pretty nice if I choose only one date (field 'CurDate').

Prev_val_22.png

But if i will choose two or more fields in 'CurDate', then expression works only for first row.

And variable in expression calculate only for first row, although in column 5 it estimates for every row.

Prev_val_3.png

Is there any ways to make it right?

So, if somebody could help I really appreciate.

Thanks in advance, Andrey

Labels (1)
1 Reply
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See this document: Calculating rolling n-period totals, averages or other aggregations


talk is cheap, supply exceeds demand