cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cze-Jhin
Frequent Visitor

How to use DAX in PowerBI according to a pivot table result in Excel?

Hi All,

I am new to PowerBI & DAX, also first time joining this community, hope you can help me with a question.

This is the raw data set also the dataset reflected in PowerBI:

OutcomeAttemptsInitiative
A1Tiger
B2Bear
C2Tiger
C1Tiger
C2Tiger
D3Lion
E1Tiger
F1Fish
F4Birds
G3Birds
H2Birds
H1Reptiles
H3Reptiles

 

In excel, the table has been pivoted into the following form:

 Outcome        
AttemptsABCDEFGHGrand Total
11 1 11 15
2 12    14
3   1  113
4     1  1
Grand Total1131121313

 

I would like to calculate a rate by dividing the grand total of column A+B+C+D (N = 6) by the grand total (N= 13). The answer should be 0.461538

 

May I know how to do that in PowerBI? I have tried to use SUMX, but it doesnt seem to work.

Please help if you can, I would appreciate it. Thank you.

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

It sounds like you want something like this:

 

Rate =
DIVIDE (
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER ( VALUES ( Table1[Outcome] ), Table1[Outcome] IN { "A", "B", "C", "D" } )
    ),
    CALCULATE ( COUNTROWS ( Table1 ), ALL ( Table1 ) )
)

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

It sounds like you want something like this:

 

Rate =
DIVIDE (
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER ( VALUES ( Table1[Outcome] ), Table1[Outcome] IN { "A", "B", "C", "D" } )
    ),
    CALCULATE ( COUNTROWS ( Table1 ), ALL ( Table1 ) )
)

View solution in original post

Hi @AlexisOlson , thank you very much for your help! I truly appreciate it!

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors