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