cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Under Over representation

Hi, I am trying to calculate an index to show over or under representation from values relative to the total.  

 

vikash_1108_0-1599251981121.png

the rows are dimension. so what I want to do is firstly the row calculation as shown already and then dividing it by the coloum total for each cell.  e.g. the first cell should calculate 0.16% divided by 0.22%. Please help

14 REPLIES 14
Highlighted

@vikash_1108 - If I understand correctly, the only thing that would change would be:

Measure 9 Row % = 
    VAR __Age = MAX([Age - Category])
    VAR __District = MAX([District - Category])
    VAR __Cell = SUM([Member ID])
    VAR __All = IF(HASONEVALUE('Table (9)'[District - Category]),COUNTROWS(FILTER(ALL('Table (9)'),[District - Category] = __District)),COUNTROWS(ALL('Table (9)')))
RETURN
    DIVIDE(__Cell,__All,0)

For __Cell, COUNT would change to SUM 


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted

HI Greg,

I Also thought that would work, but it did not.

Regards

Vikash

Highlighted

@vikash_1108 - Oh, yes, I got it, duh. Updated PBIX, Page 17, Table (17). The second measure is identical to the reference changes in the measure and table names.

Measure 17 Row % = 
    VAR __Age = MAX([Age - Category])
    VAR __District = MAX([District - Category])
    VAR __Cell = SUM([Member Count])
    VAR __All = IF(HASONEVALUE('Table (17)'[District - Category]),SUMX(FILTER(ALL('Table (17)'),[District - Category] = __District),[Member Count]),SUMX(ALL('Table (17)'),[Member Count]))
RETURN
    DIVIDE(__Cell,__All,0)

Measure 17 Column % of Row % = 
    VAR __Age = MAX([Age - Category])
    VAR __Table = ADDCOLUMNS(SUMMARIZE(FILTER(ALL('Table (17)'),[Age - Category]=__Age),[District - Category]),"__Measure",[Measure 17 Row %])
//    VAR __All = SUMX(__Table,[__Measure])
    VAR __All = IF(HASONEVALUE('Table (17)'[District - Category]),CALCULATE([Measure 17 Row %],ALLEXCEPT('Table (17)','Table (17)'[Age - Category])),[Measure 17 Row %])
    VAR __Cell = [Measure 17 Row %]
RETURN
    //IF(HASONEVALUE('Table (17)'[District - Category]),DIVIDE(__Cell,__All,0),[Measure 17 Row %])
    DIVIDE(__Cell,__All,0)


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Highlighted

Thanks a million @Greg_Deckler - This worked perfectly 🙂

Highlighted

@vikash_1108 Hooray!! 🙂


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors