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

If Condition

Hi,

Am showing the trend analysis weekly wise with symbols.

   =if( sum({$<WEEK={$(=Max(WEEK))}>}Sales) < sum({$<WEEK={$(=Max(WEEK)-1)}>}Sales) , 0,1)

When am using this expression its comparing last week sales even the last week is not in present that week is treated as '0'.

For Example:

 

Week  Sales                              

32        100

33         200

34         150

37         300


When am using that expression its taking 36th week as '0'. but i need to compare with last week if its '0' and compare with last of last week even if its '0' it should compare with another previous week. How to write the condition?

Thanks in advance


1 Solution

Accepted Solutions
luismadriz
Specialist
Specialist

You could create a MasterWeek table from Min(Week) to Max(Week) in the Load script and then have somehting like this:

Untitled.png

Would that help you?

View solution in original post

19 Replies
Anil_Babu_Samineni

condition seems okay, Perhaps anyone of these?

=if(sum({$<WEEK={'$(=Max(WEEK))'}>}Sales) < sum({$<WEEK={'$(=Max(WEEK-1))'}>}Sales) , 0,1)

OR

If(Sum(Sales) < Above(Sum(Sales)), 0,1) -- And sorting order should be Ascending


If you are using more than QV12, You can try this too

Aggr(If(Sum(Sales) < Above(Sum(Sales)), 0,1), (WEEK, (NUMERIC, ASCENDING)))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
luismadriz
Specialist
Specialist

Hi,

Is this what you're after? I'm confused about the 36th week...

Untitled.png

rkpatelqlikview
Creator III
Creator III
Author

Thanks for your response Anil.

=if(sum({$<WEEK={'$(=Max(WEEK))'}>}Sales) < sum({$<WEEK={'$(=Max(WEEK-1))'}>}Sales) , 0,1)

Its comparing with the last week.

=If(vovsdhide= 0,1,0)

=(if(ceil( sum({$<WEEK={$(=Max(WEEK))}>}) Sales)*1000)

=

ceil( sum({$<WEEK={$(=Max(WEEK)-1)}>}Sales)*1000),1,

   if(ceil( sum({$<WEEK={$(=Max(WEEK)-1)}>}Saels)*1000)=0,

    if(ceil( sum({$<WEEK={$(=Max(WEEK))}>}Sales)*1000)

=

ceil( sum({$<WEEK={$(=Max(WEEK)-2)}>}Sales)*1000),1,0)

Can i use this?

rkpatelqlikview
Creator III
Creator III
Author

Thanks Madriz,

There is no sales on 36th ans 35 th week.

This condition i should write in Textobject layout for show and hide purpose.

But little bit of confusing to write  Nested IF condition when previous week are no sales.

Anil_Babu_Samineni

If you get output, Off course, You can use it!!

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
rkpatelqlikview
Creator III
Creator III
Author

luismadriz
Specialist
Specialist

You could create a MasterWeek table from Min(Week) to Max(Week) in the Load script and then have somehting like this:

Untitled.png

Would that help you?

rkpatelqlikview
Creator III
Creator III
Author

No Anil.

My expression for this wrote in text object layout

=if(ceil( sum({$<WEEK={$(=Max(WEEK))}>}Sales)

>

ceil( sum({$<WEEK={$(=Max(WEEK)-1)}>}Sales)..   When i wrote this exprssion its comparing with last week. Here the last week is 0. its showing wrong symbol

Capture22323.PNG

Correct one is below. How will get this with if condition. i thought that there is a nested If need to use.

Capture1233.PNG

Anil_Babu_Samineni

That means, When you pick 53 there is no 52nd week. And it consider as Null. That means Null / 0 < Value - condition is wrong it should show fails only.. Does this not returned to you?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful