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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
jamiemcc
Contributor III
Contributor III

Trying to get Calculation for Previous Month

Hi Guys,

 

When trying to create a KPI for Previous Month the below Script is not working.

Its Just giving me the total overall.


if(VConceptType=1,

Sum({< Month = {"=Month(AddMonths(Today(),-1))"}>}[Judgment Total]),

If(VConceptType=2,

Count({< Month = {"=Month(AddMonths(Today(),-1))"}>}distinct[Judge ID]),

If(VConceptType=3,

sum({< Month = {"=Month(AddMonths(Today(),-1))"}>}[Total Earnings]))))

 

Any Ideas?

 

Regards,

Jamie

3 Replies
JuanGerardo
Partner - Specialist
Partner - Specialist

Hi @jamiemcc , I suppose VConceptType is a variable you are using to select which calculation to run. I think the solution could be using $(VConceptType) instead.

JG

jamiemcc
Contributor III
Contributor III
Author

Hi JuanGerardo,

 

Same Issue - Both Solutions Work.

 

The Issue seems to be here -

 

Month = {"=Month(AddMonths(Today(),-1))"}

 

Regards,

Jamie

JuanGerardo
Partner - Specialist
Partner - Specialist

Then I guess this can be caused because of the date format. You can try something like this, depending on your default date format and the way you calculate your Month dimension:

Month = {'=Num(Month(AddMonths(Today(),-1)))'}

Month = {"=Date(Month(AddMonths(Today(),-1)), 'MMM')"}

JG