Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Andrei_Faibich
Contributor III
Contributor III

Previous period data is not displayed when compared with not completed current period

On my chart I want to compare previous and current periods data. Previous period measure is conditional one:

Andrei_Faibich_0-1659691619700.png

For example, if I select 'This week' on my filter, previous period measure is calculated for previous week. But If today is Wednesday, i don't see any Thu-Sun data for previous week. The same issue is with 'This month'. If I delete conditions and write explicitly in previous perid expression:

= sum({<Period, wcOrderCreated = {">=$(=num(weekstart(today(),-1)))<$(=num(weekstart(today())))"}>}wcOrderTotal),

the chart shows me what is expected.

Andrei_Faibich_0-1659537379195.png

Thanks for any clarifications or workarounds proposed.

Labels (5)
1 Solution

Accepted Solutions
JordyWegman
Partner - Master
Partner - Master

Sorry, I checked the wrong object in your application.

I would go for a totally different solution that is way easier and faster than if statements.

Just create another field in your in Period table. Look at my example. You only need this calculation:

sum({$< Period = , PreviousPeriod = {'$(=MaxString(Period))'}>}wcOrderTotal)

You can change the MaxString to whatever fits our need, but you're off the horrible IF statement.

Jordy

Climber

Work smarter, not harder

View solution in original post

6 Replies
JordyWegman
Partner - Master
Partner - Master

Hi Andrei,

Can you share your QVF maybe with test data? It's probably the set analysis that is not working correctly. But without data, it's hard to test here.

Jordy

Climber

Work smarter, not harder
Andrei_Faibich
Contributor III
Contributor III
Author

Thanks for the prompt reply!  Here is my test app, please select 'This week' to compare. 

 

JordyWegman
Partner - Master
Partner - Master

If I do this manually I don't have any issue with the set analysis.

But you are using an IF that I don't see in my test app. So how is this working?

Jordy

Climber

Work smarter, not harder
Andrei_Faibich
Contributor III
Contributor III
Author

Hi Jordy,

I think I haven't got your question, could you please specify?

JordyWegman
Partner - Master
Partner - Master

Sorry, I checked the wrong object in your application.

I would go for a totally different solution that is way easier and faster than if statements.

Just create another field in your in Period table. Look at my example. You only need this calculation:

sum({$< Period = , PreviousPeriod = {'$(=MaxString(Period))'}>}wcOrderTotal)

You can change the MaxString to whatever fits our need, but you're off the horrible IF statement.

Jordy

Climber

Work smarter, not harder
Andrei_Faibich
Contributor III
Contributor III
Author

Hi Jordy, 

Thank you so much for the solution proposed!

I have created "Previous" field as you advised and it works exactly as I need.

Andrei_Faibich_0-1660975244503.png

What I learned from many cases for now that Qlik doesn't like if() statements in dimension/measure expressions