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

Odd and even years

hello,

We have data coming in every alternate year 2 different departments. For example, 2018 we get data for Department A, 2019 for Department B, 2020 for Department A, 2021 for Department B and so on...

I would like to display a text based off the year, for even years - it should display the

even years - department A 

odd years - Department B

How can I write the set expression to achieve this?

1 Solution

Accepted Solutions
jwjackso
Specialist III
Specialist III

Use the same logic that displays the previous year's data to populate the year in the formula

If(Mod (Year,2) = 0,'Department A','Department B')

Not the selected year

 

 

View solution in original post

6 Replies
jwjackso
Specialist III
Specialist III

Why not use an "IF" statement

 

If(Mod (Year,2) = 0,'Department A','Department B')

 

analyticsuser
Contributor
Contributor
Author

Thank you. It works. 

Also, I have to display text that says data is for 2018 for Department A, when the user clicks on 2019, it should still say data displayed is for 2018 Department A as technically there's no data in 2019 for Department A. When user clicks 2020, it should say data displayed is for 2020 Department A. 

2018 - Data is for 2018 Department A

2019 - Data is for 2018 Department A

2020 - Data is for 2020 Department A

In the text, Do I need a variable for on year to manipulate the year? 

 

jwjackso
Specialist III
Specialist III

Why is data still showing if you choose a year without data?

analyticsuser
Contributor
Contributor
Author

That was the client's requirement to display previous year's data. They didn't want it to be blank.

jwjackso
Specialist III
Specialist III

Use the same logic that displays the previous year's data to populate the year in the formula

If(Mod (Year,2) = 0,'Department A','Department B')

Not the selected year

 

 

analyticsuser
Contributor
Contributor
Author

So you mean, Data displayed below for Department A is from & &' if(Mod(Year,2) = 0,'DepartmentA,'DepartmentB') ?? the expression doesn't work. 

I need to show the text as "Data displayed for Department A is from 2018" - when 2018 is selected

"Data displayed for Department A is from 2018" - when 2019 is selected

"Data displayed for Department A is from 2020" - when 2020 is selected

Same way for Department B

"Data displayed for Department B is from 2019" - when 2019 is selected

"Data displayed for Department B is from 2019" - when 2020 is selected

"Data displayed for Department B is from 2021" - when 2021 is selected

Hope I'm explaining the requirement clearly. Thank you for your help.