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

selection of year and month in filter has to show previous year and month sales

Hi,

I've the below table.

Year YearMonth Market Sales
2024 2024-Jan IND 100
2024 2024-Feb ANZ 200
2024 2024-Mar NAM 300
2023 2023-Jan IND 150
2023 2023-Feb ANZ 250
2023 2023-Mar NAM 350
2022 2022-Jan IND 160
2022 2022-Feb ANZ 260
2022 2022-Mar NAM 360

 

my requirement if user selects 2024 from Year filter and 2024-Jan and 2024-Feb from YearMonth is has to show 2024 Year and 2023 Previous Year Sales. Below is what I'm expecting.

Year 2024 Year Sales 2023 Year Sales
2024 300 400

 

if user selects 2023 from Year filter and 2023-Jan and 2023-Feb from YearMonth is has to show 2023 Year and 2022 Previous Year Sales. Below is what I'm expecting.

Year 2023 Year Sales 2022 Year Sales
2023 400 420

 

2 Replies
anat
Master
Master

Create month number field in back end script then

Current Year YTD:

Sum({<Year={$(=max(Year))},MonthNum={'<=$(=max({<Year=$(=max(Year))}>}MonthNum))'}>}Sales)

Previous Year YTD:

Sum({<Year=,Year={$(=max(Year)-1)},MonthNum={'<=$(=max({<Year=$(=max(Year))}>}MonthNum))'}>}Sales

vikasshana
Creator II
Creator II
Author

without adding MonthNum in the backend, can't we directly do in the front end set analysis?