Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
MoCho
Contributor II
Contributor II

Set Analysis Not working

Hi

I'm trying to do period comparisons in Qlik Sense - Current month vs Last Month vs Same Month Last year etc. I have the following variables in my load script:

let vMaxDate = '=max(Date)';
let vMaxDay = '=day(max(Date))';
let vMaxMonth = '=month(max(Date))';
let vMaxYear = '=max(Year)';
let vPriorMonth = '=month(addmonths(max(Date),-1))';
let vPriorMonthYear = '=Year(addmonths(max(Date),-1))';
let vPriorYear = '=vMaxYear-1';

On my sheet, I created a Master measure as follows:

SUM({<Year={'$(vMaxYear)'},Month={'$(vMaxMonth)'},Day=,Date=,MonthYear=,MonthNum=>}NetSalesValue)

 

The issue I'm facing is that the result is the sum of the Max Year. The Month part is not being considered even though is shows as OK and is being picked up in the expression window. See attached image.

Am I missing something?

Also, how would I the go about calculating the other periods?

 

1 Solution

Accepted Solutions
Rohan
Specialist
Specialist

Hi Mocho,

In your image, you can see that Month & Day are not getting considered as Dimensions, instead Qlik is considering them as Qlik Functions. Please check if the dimension names are correct for them or not in your script. if the names are correct then try placing them in '[..]' once & check if that is working.

PS : Fields will be in Orche/Yellowish colour & Functions in Blue in expressions.

Regards,

Rohan. 

View solution in original post

6 Replies
qv_testing
Specialist II
Specialist II

Variables will not work as you created and my suggestion is to create those variables in UI.

Rohan
Specialist
Specialist

Hi Mocho,

In your image, you can see that Month & Day are not getting considered as Dimensions, instead Qlik is considering them as Qlik Functions. Please check if the dimension names are correct for them or not in your script. if the names are correct then try placing them in '[..]' once & check if that is working.

PS : Fields will be in Orche/Yellowish colour & Functions in Blue in expressions.

Regards,

Rohan. 

Chanty4u
MVP
MVP

Try this

SUM({<Year={'$(vPriorMonthYear)'}, Month={'$(vPriorMonth)'}>} NetSalesValue)

Same month last year

SUM({<Year={'$(vPriorYear)'}, Month={'$(vMaxMonth)'}>} NetSalesValue)

 

vinieme12
Champion III
Champion III

 is Month field Text or Numeric?

 

Alternatively  You can filter for current month as as below 

=SUM({< Date ={">=$(=Date(MonthStart(Max(Date))))<=$(=Date(Max(Date)))"} >}NetSalesValue)

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
MoCho
Contributor II
Contributor II
Author

Thanks Rohan. You were right, my Month field had a different name.

MoCho
Contributor II
Contributor II
Author

Thank you

These worked for the other periods