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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jjac_pbi_1979
Frequent Visitor

SUM divide results with dax

Hello. I am trying to do following: 

 

I have measure A and measure B. Then I need to do DIVIDE(A,B), to get C. 

 

So, for example, I have following results: 

 

ABC
1025
842
1234

 

I need to get the SUM of C. Let's say 5+2+4 = 11.

Instead, I get (10+8+12) / (2+4+3) which is a completelly different result.

 

I am grouping this by Country, but all, the Country column, measure A and measure B are all being calculated, are not physical values stored on a table. 
Said that, the visual I have is something like following. I which to have a Total Row saying 11, as I show in the example below, but instead I get 3.33, as it calculates SUM(A) / SUM(B).

 

CountryDivided value
Mexico5
Canada2
Japan4
Total11

 

Please provide your comments, it would be really helpful to me. 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @jjac_pbi_1979 

 

You can try the following methods. The function IF (HASONEVALUE ( )) controls the output value of total.

Divided value = 
IF (
    HASONEVALUE ( 'Table'[Country] ),
    DIVIDE ( SUM ( 'Table'[A] ), SUM ( 'Table'[B] ) ),
    SUMX (
        SUMMARIZE (
            'Table',
            'Table'[Country],
            "DIVIDE", DIVIDE ( SUM ( 'Table'[A] ), SUM ( 'Table'[B] ) )
        ),
        [DIVIDE]
    )
)

vzhangti_0-1655454207901.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @jjac_pbi_1979 

 

You can try the following methods. The function IF (HASONEVALUE ( )) controls the output value of total.

Divided value = 
IF (
    HASONEVALUE ( 'Table'[Country] ),
    DIVIDE ( SUM ( 'Table'[A] ), SUM ( 'Table'[B] ) ),
    SUMX (
        SUMMARIZE (
            'Table',
            'Table'[Country],
            "DIVIDE", DIVIDE ( SUM ( 'Table'[A] ), SUM ( 'Table'[B] ) )
        ),
        [DIVIDE]
    )
)

vzhangti_0-1655454207901.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

FarhanAhmed
Community Champion
Community Champion

Create a measure like 

 

_Divide SUM = SUMX(Values(table[country]), Divide(MeasureA,MeasureB))






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

Proud to be a Super User!




Thank you so much. Will try that and will confirm if works to accept it as solution. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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