Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
ramyasaiqv
Creator II
Creator II

Calculate selected values only in set expression

Hi All,

I have a requirement tried to  achieve using set analysis but as i'm not really good at set analysis not able to accomplish. So here i'm please help me

I'm trying to  this calculation

Total = sum({<flag={'Standard'}>}recalculated) + sum(0.4*(Count))-

sum({<flag={'Sponsorship'}>}Total)

(Total ="sum of recalculate when flag= ‘Sponsorship’ + sum of 40% of (count) – sum of Total when flag= ‘Standard’  )

By default the app should aggregate sum (recalculated) +sum(count)+ sum(total) but if the user makes a selection on the Flag value(Sponsorship or standard) it calculate the sum of the selected flag condition

for example if a selection is made on flag value 'standard' then the it should sum ( sum({<flag={'Standard'}>}recalculated) + sum(0.4*(Count)) only.. it should dis regard sum({<flag={'Sponsorship'}>}Total)

or if a selection is made on lag value 'Sponsorship' the expression should sum 

sum(0.4*(Count))-

sum({<flag={'Sponsorship'}>}Total)  excluding sum({<flag={'Standard'}>}recalculated).

I have attached the sample qvw and excel data for reference.  Please help me . Thank you,

21 Replies
Anil_Babu_Samineni

Don't worry. Community with you and legends are there. No need to say sorry but free to ask if the issue was tiny / Huge

You already did that

If(Flag = 'Sponsorship', 1, 0) as Sponsorship,

If(Flag = 'Standard', 1, 0) as Standard


Those two conditions if conditions only as i mentioned. You did great job

For future level if you like to use Sponsorship and Standard you can use like below


Sum({<Sponsorship = {'1'}, Standard = {'1'}>}Sales)


This will work out


If it turns to me, I will write those into simple single line future


If(Flag = 'Sponsorship' and Flag = 'Standard' , 1, 0) as FlagSponsorStrd,


If you want to happen selectors by using Sponsorship and Standard then you can do something like below


Sum({<FlagSponsorStrd = {'1'}>}Sales)

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
ramyasaiqv
Creator II
Creator II
Author

Thank you Anil.