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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.