Forum Discussion
Pivot table and then divide columns
I have a pivot table that looks like this:
I am trying the replace column 'WK 1' with 'WK 1' / 'Num of Active Users' * 100 (expressed as %). Additonally, I am trying to do a conditional BG format only on rows WK 1 to WK 5. How can I do so?
Utilmately, I want my end product to look like this.
I did this by instead of forming the pivot table as a matrix, I did the pivot in the edit query and was able to do calculations on each individual column. The data that I am pivotting looks like this:
My pivot operation looks like this:
in order to apply the formatting you where after.
Create a seconf measure called formating as below
it is nearly identical to my first measrue but in this version in the switch statment the active users colunm is replaced with blank
Formatting = --get number of active users var activeusers = CALCULATE(sum('Copy of temp (1)'[cnt_pax]),'Copy of temp (1)'[week_diff] = "NUM OF ACTIVE USERS") --get value to divide by var cnt_p = sum('Copy of temp (1)'[cnt_pax]) --find the colunm header value var sv = SELECTEDVALUE('Copy of temp (1)'[week_diff]) -- calculate teh value divided by the active users * 100 var diff = DIVIDE(cnt_p,activeusers)*100 -- switch the value based on the header colunm, for active user header use active user value for all others user DIFF var ret = SWITCH(sv,"NUM OF ACTIVE USERS",blank(),diff) -- return the values return retthen in the conditional formating section select background colour on, and in the advanced options use the follwoing settings
the Based on filed use the new formating measure, and make sure that the default formatting is set to dont fomrat
then ensure that diverging is ticked and select your three colurs
9 Replies
- AnthonyTilley
Solution Sage
Can you provide some sample data
Or better yet a sample PBIX file
- AnonymousNot applicable
- AnthonyTilley
Solution Sage
sorry not sure if im missing something here but the sample data you provided does not ahve anything realting to number of active users