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

Same period CY vs same period LY

Hi 

I have "Date" and "Amount" field in my fact table. I need to calculate Year wise sales.

But make sure I want Current year till today vs last all years same date.

Suppose, for 2019 it should show from 1-1-2019 to 5-5-2019

for 2018, 1-1-2018 to 5-5-2019

for 2017, 1-1-2017 to 5-5-2017

and so on

I want to create one measure expression that should give me the above result.

Thank You

Labels (1)
3 Replies
Lisa_P
Employee
Employee

If you have brought your data in using data manager, you can create these measures using the create calendar measures, by right clicking on the Sales field and selecting Create calendar measures. IT should detect the date field and select Sum for aggregation and Yearly as time range.

It will automatically create 3 Master Measures in the Mast items for the Year to date Sales (all years) as well as the Current YTD and Last YTD.

If you are loading using the Data Load editor, you should create these in the Master Calendar.
Shahzad_Ahsan
Creator III
Creator III
Author

Hi @Lisa_P 

I have created master calendar, only i need to create the measure to get the exact solution.

Lisa_P
Employee
Employee

If you have created the CYTD and LYTD flags in your Master calendar, they can be applied in set analysis in your master measure.
Sum({$< CYTDFlag={1}, Year=, Quarter=, Month= >}Amount)
Sum({$< LYTDFlag={1}, Year=, Quarter=, Month= >}Amount)