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: 
Ayushs
Contributor II
Contributor II

previous month count

Hi All,

I am trying to find a % change from selected months sales to previous month sale. I have data from Jan to Sep . and filter pane in which values are (Jan, feb, mar to sep) so if I select months, the % change will appear in the KPI.

How should I write set expression keeping these condition in mind?  Date field format (2020 -04-24)

Please help!!

 

Labels (2)
7 Replies
Vegar
MVP
MVP

Something like I've done below. 

Sum(sales) / sum({<Month=, Date={">=$(=monthstart(min(Date), - 1)) <$(=monthend(min(Date),-1)) >} Sales) 

Ayushs
Contributor II
Contributor II
Author

Hi Vegar

this is what I am getting .  Day_fact is my date field

Ayushs_0-1607847104362.png

 

Ayushs
Contributor II
Contributor II
Author

Hi

PFB I have edited the expression as per data. Day_fact is my date field. it shows null value

Ayushs_0-1607850313689.png

 

Vegar
MVP
MVP

See my minor adjustments '  '. 

Count (distinct patient_id) / sum(distinct {<Month=, day_fact={">='$(=monthstart(min(day_fact), - 1))' <'$(=monthend(max(day_fact),-1))' >} patient_id) 

Ayushs
Contributor II
Contributor II
Author

output

Ayushs_0-1607856022093.png

 

Kushal_Chawda
MVP
MVP

@Ayushs  try below

Count (distinct patient_id) / sum(distinct {<Month=, day_fact={">=$(=date(monthstart(addmonths(max(day_fact), - 1))))<=$(=date(monthend(addmonths(max(day_fact), - 1))))" }>} patient_id) 

Vegar
MVP
MVP

What's wrong with the output?

By the way, it does not look like you are selecting a single month in the screenshot you posted.  Your intensely is larger than a month. If so, what period do you want to compare with?