简体   繁体   中英

Conditional division in power BI DAX

I have two tables, one has a column gross profit and the other has total sales and category . I want to divide gross profit by total sales where category = SGA .

How do I get there?

Create measure:

Gross Margin =
CALCULATE (
    DIVIDE ( SUM ( Table1[Gross Profit] ), SUM ( Table2[Total Sales] ) ),
    Table2[Category] = "SGA"
)

Note: it will only work if you slice it by shared dimensions. If you run into issues, post your data model snapshot - DAX formulas are highly dependent on the model relations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM