Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Marcus_E
Helper I
Helper I

Converting measure value to a negative number

Hi 

 

I'm struggling to resolve an issue I have with a calculated measure returning a positive value when it's calculating using two negative inputs.

 

We issue out materials to order numbers and I want to calculate the total value of materials issued to orders. There are two input measures that work as they should: Material Quantity and Unit Price. The final measure I'm struggling with is called Extended Price:    Extended Price = [Unit Price]*[Material Quantity]. 

 

This works fine when the Unit Price or Material Quantity are positive numbers, however the problem is when either are negative (when a material item is removed or credited off an order number it will display in the transaction as a negative. This in itself is fine but I need the calculated Extended Price measure to reflect the negative result and currently when both the Unit Price and Material Quantity are negative, the Extended Price result is showing as positive.

 

Am I missing something here, and what can anyone suggest that I do to ensure the Extended Price returns a negative value when either or both the Unit Price or Material Quantity are negative (usually it's both negative).

 

Thank you.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Well, you are asking to change the rules of math. -1 * -1 = 1. Multiplying two negatives creates a positive. That's just math man.

 

However, if you want to defy tens of thousands of years of mathematics, I can respect that. Boo...Math!!

 

Extended Price =
  VAR __ExtendedPrice = [Unit Price] * [Material Quantity]
RETURN
  IF([Unit Price] < 0 && [Material Quantity] < 0, -1 * __ExtendedPrice,__ExtendedPrice)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
dax
Community Support
Community Support

Hi @Marcus_E ,

I am not clear about your requirement, if possible could you please inform me more detailed information(such as your expected output and your sample data (by OneDrive for Business))? Then I will help you more correctly.

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Marcus_E ,

Try like

sumx(Table, Switch(true(),
Table[Unit Price]<0 && Table[Material Quantity] <0 , -1*Table[Unit Price] * Table[Material Quantity] ,
Table[Unit Price] * Table[Material Quantity]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

Well, you are asking to change the rules of math. -1 * -1 = 1. Multiplying two negatives creates a positive. That's just math man.

 

However, if you want to defy tens of thousands of years of mathematics, I can respect that. Boo...Math!!

 

Extended Price =
  VAR __ExtendedPrice = [Unit Price] * [Material Quantity]
RETURN
  IF([Unit Price] < 0 && [Material Quantity] < 0, -1 * __ExtendedPrice,__ExtendedPrice)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks, I'm well aware of the said rules of basic mathmetics - my question was how to portray the negative value as a negative in order to report the final total accurately.

 

Thanks again.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors