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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Morkil
Helper I
Helper I

Calc Item to return measures multipled by -1

I'm creating a calculation item that, when applied as a filter, flips the negative or positive signs of a number to the opposite.

 

e.g., if a cost is -5000, using this calc item will make it 5000.

 

So far I am using:

IF(CONTAINSSTRING (SELECTEDMEASURENAME (), "Cost") || IF(CONTAINSSTRING (SELECTEDMEASURENAME (), "Revenue") ,
SELECTEDMEASURE () * -1,
SELECTEDMEASURE ())

 

This works great if the measure itself contains the string "Cost" or "Revenue" in it. I'd like to know if there is a means of achieving the above without doing a string match, but instead checking the underlying DAX of a measure and then computing from there.

 

e.g., measure is "Entertainment Cost", which can be calculated by Cost filtered by Entertainment. 

CALCULATE([Cost],
Dim[Cost Type] = "Entertainment")

 

How can I check if the measure itself is referring to either the dependent "cost" measure or column above and then doing the flipping of the negative/positive sign.

 

Thanks.

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Morkil 

A calculation item can't reference either the DAX code or the measure dependencies of SELECTEDMEASURE ().

 

If you need to selectively apply a calculation item to measures within DAX expressions, so that the calculation item is applied to either [Cost] or [Revenue] within DAX expressions, I suggest following the method in this article:

https://www.sqlbi.com/articles/using-calculation-groups-to-selectively-replace-measures-in-dax-expre...

 

Note: The INFO.CALCDEPENDENCY function does return dependency information and can be used when querying the model, but cannot be used in measure, calculated column or calculated table definitions.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @Morkil 

A calculation item can't reference either the DAX code or the measure dependencies of SELECTEDMEASURE ().

 

If you need to selectively apply a calculation item to measures within DAX expressions, so that the calculation item is applied to either [Cost] or [Revenue] within DAX expressions, I suggest following the method in this article:

https://www.sqlbi.com/articles/using-calculation-groups-to-selectively-replace-measures-in-dax-expre...

 

Note: The INFO.CALCDEPENDENCY function does return dependency information and can be used when querying the model, but cannot be used in measure, calculated column or calculated table definitions.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn
OwenAuger
Super User
Super User

Hi @Morkil 

A calculation item can't reference either the DAX code or the measure dependencies of SELECTEDMEASURE ().

 

If you need to selectively apply a calculation item to measures within DAX expressions, so that the calculation item is applied to either [Cost] or [Revenue] within DAX expressions, I suggest following the method in this article:

https://www.sqlbi.com/articles/using-calculation-groups-to-selectively-replace-measures-in-dax-expre...

 

Note: The INFO.CALCDEPENDENCY function does return dependency information and can be used when querying the model, but cannot be used in measure, calculated column or calculated table definitions.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.