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
tiago
Helper I
Helper I

[HELP] How to Create a measure with Sum If

ProductColorSalesStockTotal Ordered (Sales + Stock)% Sales / Total Order
ABlack10020030033%
AGray20010030067%
ABlue3005035086%
BYellow1003013077%

 

I need to create the Total Ordered (Sales + Stock Measure) and the % Sales/Total Order measure

 

What I am trying to do is 

 

Measure = DIVIDE(SUM('TABLE'[SALES]);(SUM('TABLE'[SALES])+SUM(TABLE[STOCK])))

 

It is not working because this view is shown by color, and the way I've done it it SUMS all product A sales and divides per all product A sales + stock. I needed to get the sales per color.

 

Any help is appreciated.

 

Thanks in advance,

 

Regards,

Tiago

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @tiago,

 

I tested with your provided measure, it returned the same result as shown in above sample table.

1.PNG

 

Is this your expected result? Would you please share your sample .pbix file for a test?

 

Regards,

Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
themistoklis
Community Champion
Community Champion

@tiago

 

use ALLEXCEPT fuction to divide

 

Measure = DIVIDE(SUM('TABLE'[SALES]); CALCULATE((SUM('TABLE'[SALES])+SUM(TABLE[STOCK])), ALLEXCEPT('TABLENAME', TABLENAME[COLOR])

tiago
Helper I
Helper I

If I isolate only one product.  and use this measure.

Measure =  DIVIDE(SUM('TABLE'[SALES]);(SUM('TABLE'[SALES])+SUM(TABLE[STOCK])))

 

It returns many lines with duplicated values but with the correct calculation. But something is wrong with the measure, becuse when I add it to my table, the table that has 1 product and 3 colors explodes to have many lines. 

 

There is probably a proper way to do this.


Regards,

Tiago

Hi guys, couldnt figure this one out still. Please help

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.