Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
I have following table in BI.
| Item | Cost |
| 18" Alloy | -23000 |
| 20" Alloy | 31000 |
| Air Bag | 5000 |
| Deatc | 250 |
I want to subtract 18" Alloy cost(-23000) from 20" Alloy(31000) and remove 18" Alloy from the table. I Used following Dax function and it returns above table as out without doing any subtraction. Please correct my code or help me with new code. Thank you in advance.
Used DAX:
IF (
[Item] = "20"" Alloy",
[Costs] +
CALCULATE (
SUM([Costs]),
[Item] = "18" Alloy"
),
FJ11_16[Calculated Costs]
)
Desired Output:
| Items | Cost |
| 20" Alloy | 8000 |
| Air Bag | 5000 |
| Deatc | 250 |
Solved! Go to Solution.
Hi @Singh_Yoshi
Please try this:
Measure1 =
VAR _alloy =
CALCULATE (
SUM ( SampleData[Cost] ),
FILTER (
ALL ( SampleData[Item], SampleData[Cost] ),
SampleData[Item] IN { "18"" Alloy", "20"" Alloy" }
)
)
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( SampleData[Item] ) = "18"" Alloy", BLANK (),
SELECTEDVALUE ( SampleData[Item] ) = "20"" Alloy", _alloy,
SUM ( SampleData[Cost] )
)
Hi @Singh_Yoshi
Please try this:
Measure1 =
VAR _alloy =
CALCULATE (
SUM ( SampleData[Cost] ),
FILTER (
ALL ( SampleData[Item], SampleData[Cost] ),
SampleData[Item] IN { "18"" Alloy", "20"" Alloy" }
)
)
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( SampleData[Item] ) = "18"" Alloy", BLANK (),
SELECTEDVALUE ( SampleData[Item] ) = "20"" Alloy", _alloy,
SUM ( SampleData[Cost] )
)
I have a following table called Table1,
| Model Code | MSRP | LC |
| FJ11 | 1392000 | |
| FJ16 | 1580000 | 188000 |
| FJ7 | 1762000 | 182000 |
| FJ8 | 1912000 | 150000 |
| FJ15 | 1937000 | 25000 |
| FJ12 | 2279000 | 342000 |
I have few measures as below names and consists of Items and Cost
1. Now I want to subtract LC cost - SUM of each measure
2. I need the percentage of (LC Cost - Sum of each measure)
Kindly help me with DAX code
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 64 | |
| 56 | |
| 43 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 123 | |
| 108 | |
| 44 | |
| 32 | |
| 24 |