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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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 ) )
)

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.