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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik1_User1
Specialist
Specialist

Help with set analysis

Hi, 

Please help with this requirement.=, this needs to be done in UI not at Modeling side

Year Amt 2020 100 2021 200 2022 300 2023 400 2024 500 2025 600 2026 700 2027 800

 

NOTE we need to represent year>current years means 2026, 2027 as 2026(next), 2027(Next) on bar chart 

Requirement - create a Bar chart with year as dim and measure as sum of Amt
Case 1 No year selected show current year -2 to Current year +2 (2023,2024,2025,2026,2027)
Case2 If current year selected show current, and next two year (2025, 2026, 2027)
Case 3 If except current year any other selected show only that year.

Labels (7)
1 Reply
Qlik1_User1
Specialist
Specialist
Author

Create Variable:
vCurrentYear=Year(now())

In a bar ,use this expression:
If(
GetSelectedCount(Year) = 0,
Sum({
<Year={">=$(=AddYears($(vCurrentYear), -2))<=$(=AddYears($(vCurrentYear), 2))"}>
} Amt),

If(
GetFieldSelections(Year) = '$(vCurrentYear)',
Sum({
<Year={">=$(=$(vCurrentYear))<=$(=$(vCurrentYear)+2)"}>
} Amt),

Sum({
<Year={"=$(=Only(Year))"}>
} Amt)
)
)