Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Sebastian_Dec
Creator II

Sum month and previous month -

Hi, I see, a lot of this topic, but I have some strange error that I don't understand.

I have a very simple table and calculated MonthAgo and Month Number and Sales. In the last fourth column, I want to show the total sales from the previous month.

Sebastian_Dec_0-1699031312800.png

My code is:

Sum({<MonthsAgo={"$(= '=' & (Min(MonthsAgo)+1))"}, Month=, Data= >} sales)

Even Qlik tells me it's ok, and yet the third and fourth columns have the same results -> I don't understand it.

 

Thanks & Regards,
Please close the thread by marking correct answer & give likes if you like the post.
Labels (1)
2 Solutions

Accepted Solutions
Aditya_Chitale
Specialist

@Sebastian_Dec 

why don't you use below() function ?

=below(TOTAL sum(sales))

in the measure totals expression, select "Sum".

Aditya_Chitale_0-1699265384303.png

 

Regards,

Aditya

View solution in original post

Gabbar
Specialist

It is because of aggregation in tables,
Your measure is aggregated on Dimension Present in Table according to set analysis, 
So if the set and the dimension are conflicting it either gives dimension values or null, Depending upon Qlik version (Sometimes it changes even after Refreshing)

The best way to solve it in UI is aggregating your measure your self on those dimension and change measure into calculative dimension, rather then letting Qlik do it to a measure.

View solution in original post

4 Replies
ajaykakkar93
Specialist III

Hi,

Use AddMonths()

Sum({<MonthsAgo={"$(=AddMonths(Min(MonthsAgo),-1))"}, Month=, Data= >} Year)

 

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

Aditya_Chitale
Specialist

@Sebastian_Dec 

why don't you use below() function ?

=below(TOTAL sum(sales))

in the measure totals expression, select "Sum".

Aditya_Chitale_0-1699265384303.png

 

Regards,

Aditya

Gabbar
Specialist

It is because of aggregation in tables,
Your measure is aggregated on Dimension Present in Table according to set analysis, 
So if the set and the dimension are conflicting it either gives dimension values or null, Depending upon Qlik version (Sometimes it changes even after Refreshing)

The best way to solve it in UI is aggregating your measure your self on those dimension and change measure into calculative dimension, rather then letting Qlik do it to a measure.

Sebastian_Dec
Creator II
Author

@ajaykakkar93 ,  thanks for your help but function not working.
@Aditya_Chitalethanks for your help, It works 🙂
@Gabbar you're right, the function didn't want to work in the standard table.
When I moved it to the piviot table, Row = shops, artId / Column = Values / Measures = function it works very good.

 

Of course, there was a problem that when adding Column = Months, I can't count e.g. October and September together because there is a FIXED filter for a given month, but I managed to write 12 functions for 12 months...

Thanks & Regards,
Please close the thread by marking correct answer & give likes if you like the post.