Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rahulsingh12
Contributor III
Contributor III

Set Analysis Issue

hi I have a case as below:

State and corresponding volume and a flag for each state

STATEVOLFLAG
MH10SW
MH20SR
RJ10SR
JH10SR
GJ45SR
MH56SR

Here I want to calculate the if the state is MH then take vol for flag 'SW' and for all other take SR.

This vol has to be divided by the total vol to get the percentage.

The value in State field will keep changing so cannot hard code the value in expression so I thought of set analysis but it is giving me some wrong data:

sum({<STATE={'MH'},FLAG={'SW'}>}VOL)/(TOTAL VOL SW FOR MH AND SR FOR REST OF THE STATE)

+

SUM({<STATE-={'MH'},FLAG={'SR'}>}VOL)/(TOTAL VOL SW FOR MH AND SR FOR REST OF THE STATE)


Regards,

5 Replies
Anil_Babu_Samineni

May be share full expression and result set needed?

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
jonathandienst
Partner - Champion III
Partner - Champion III

To simplify the set expression and get % of total:

=Sum({<STATE = {'MH'}, FLAG = {'SW'}> + <STATE -= {'MH'},FLAG = {'SR'}>} VOL) /

(Sum({<STATE={'MH'},FLAG={'SW'}>+<STATE-={'MH'},FLAG={'SR'}>} TOTAL VOL)

You want to calculate total for others:

=Sum({<STATE = {'MH'}, FLAG = {'SW'}> + <STATE -= {'MH'},FLAG = {'SR'}>} VOL)/

(Sum({<STATE={'MH'},FLAG={'SW'}>+<STATE-={'MH'},FLAG={'SR'}>} TOTAL VOL)

- Sum({<STATE = {'MH'}, FLAG = {'SW'}> + <STATE -= {'MH'},FLAG = {'SR'}>} VOL))

This can be arithmetically simplified to\

=Sum({<STATE = {'MH'}, FLAG = {'SW'}> + <STATE -= {'MH'},FLAG = {'SR'}>} VOL)/

Sum({<STATE={'MH'},FLAG={'SW'}>+<STATE-={'MH'},FLAG={'SR'}>} TOTAL VOL) - 1

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
sunny_talwar

Is this what you are looking to get?

Capture.PNG

I used this expression

Sum({<STATE *= {'MH'}, FLAG *= {'SW'}>+<STATE -= {'MH'}, FLAG = {'SR'}>} VOL)/Sum(TOTAL {<STATE *= {'MH'}, FLAG *= {'SW'}>+<STATE -= {'MH'}, FLAG = {'SR'}>} VOL)

rahulsingh12
Contributor III
Contributor III
Author

Hi Sunny with this expression If i select GJ it shows data for GJ as well for MH.

I don't want data for MH when I select GJ.

Is there something I am doing wrong.

Regards,

Rahul

sunny_talwar

I don't see this behavior

Capture.PNG

Only thing you might do different is to use this expression so that the percentage doesn't change to 100% when you select a STATE

Sum({<STATE *= {'MH'}, FLAG *= {'SW'}>+<STATE -= {'MH'}, FLAG = {'SR'}>} VOL)/Sum(TOTAL {<STATE = {'MH'}, FLAG *= {'SW'}>+<STATE = -{'MH'}, FLAG = {'SR'}>} VOL)

Capture.PNG