- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

How to have measure variance to flip the sign
As the subject says, I'm trying to create a measure that shows the variance between 2 measures - [measure_PrevAmount] and [measure_CurrAmount].
After googling, although was told that I could use SWITCH, my question now is that, given that my table could collapse or expand depending on user's view, I want to show the correct variance calculation.
As shown in the print screen, I have 6 cost codes, that made up of 'Revenue' category. But it's sub categories are 'Items Sold' (Obj_Code 1500, 1501 and 1502) and 'Promotions' (Obj_Code 1520, 1530 and 1540).
How can I flip the sign when it's Obj_Code 1500, 1501 and 1502 even though it's not showing in the table? In other words, those highlighted variance in yellow need to show positive amount, and that the Revenue subtotal will show 185 instead of -215
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,
Try these measures
Measure = if(Data[Obj_code]="1500"||Data[Obj_code]="1501"||Data[Obj_code]="1502",[measure_curramount]-[measure_prevamount],[measure_prevamount]-[measure_curramount])
Measure2 = SUMX(VALUES(Data[Cost code]),[Measure])
Hope this helps.
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @JustDavid
Please try this:
CALCULATE ( - [Variance], KEEPFILTERS ( 'table'[Sub Category] = "Items Sold" ) )
+ CALCULATE ( [Variance], KEEPFILTERS ( 'table'[Sub Category] <> "Items Sold" ) )
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @JustDavid
You can use the measure :
Variance =
VAR itemsSoldVariance =
SUMX(
FILTER( 'Table', 'Table'[Sub category] = "items sold" ),
('Table'[prev amount] - 'Table'[curr amount]) * -1
)
VAR otherVariance =
SUMX(
FILTER( 'Table', 'Table'[Sub category] <> "items sold" ),
'Table'[prev amount] - 'Table'[curr amount]
)
VAR totalVariance =
SUMX(
'Table',
IF( 'Table'[Sub category] = "items sold",
('Table'[prev amount] - 'Table'[curr amount]) * -1,
('Table'[prev amount] - 'Table'[curr amount])
)
)
RETURN
IF( HASONEVALUE('Table'[Category]), itemsSoldVariance + otherVariance, totalVariance )
Result:
Pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@Ritaf1983 Instead of using Table[Sub category], if I want to incorporate your formula with [Obj_code], how do I take into consideration of 1500, 1501 and 1502?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @JustDavid
This is the same logic, different condition :
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @JustDavid ,
Based on the sample data you provided, could you clarify what your expected result is? To help us investigate further, would you kindly share additional details, specific examples, and a supporting screenshot illustrating the issue? Thank you for your assistance.
@Ritaf1983 Instead of using Table[Sub category], if I want to incorporate your formula with [Obj_code], how do I take into consideration of 1500, 1501 and 1502?
Best Regards
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,
Try these measures
Measure = if(Data[Obj_code]="1500"||Data[Obj_code]="1501"||Data[Obj_code]="1502",[measure_curramount]-[measure_prevamount],[measure_prevamount]-[measure_curramount])
Measure2 = SUMX(VALUES(Data[Cost code]),[Measure])
Hope this helps.
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

To get the correct Grand Total.
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,
Try these measures
Measure = if(Data[Obj_code]="1500"||Data[Obj_code]="1501"||Data[Obj_code]="1502",[measure_curramount]-[measure_prevamount],[measure_prevamount]-[measure_curramount])
Measure2 = SUMX(VALUES(Data[Cost code]),[Measure])
Hope this helps.
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
07-27-2024 05:00 PM | |||
09-27-2023 07:25 AM | |||
08-21-2024 05:02 AM | |||
07-10-2024 04:46 AM | |||
12-12-2020 11:31 PM |
User | Count |
---|---|
83 | |
70 | |
62 | |
39 | |
38 |