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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
apagan
Helper I
Helper I

Correct formula to get two columns multiplied against each other

I need assistance with the following formula to get the following:

 

The value of two columns multiplied by each other ( [litre] * [concentration] ) and the results of that equation multipled by 15.99.  I only want to perform that calculation on the rows in a table where [result]="Fail". 

 

I've tried the below, formula, but cannot get it to work.

 

 

CALCULATE(table[Fail],(table[Litre]*table[concentration])*15.99)

 

Thanks, in advance!

 

2 ACCEPTED SOLUTIONS
vrs
Frequent Visitor

To use a measure try using SUMX

 

Measure = CALCULATE(SUMX('Table';'Table'[Litre]*'Table'[Concentration]*15,99); FILTER('Table';'Table'[result]="Fail"))

View solution in original post

vrs
Frequent Visitor

in the expr of SUMX(table, expr), you can put any mathematic logic you need.

 

in the same formula change the SUMX expression to

SUMX('Table';'Table'[Litre]-('Table'[Litre] * 'Table'[Concentration]*15,99))

 

 

hope this helps 🙂

View solution in original post

4 REPLIES 4
vrs
Frequent Visitor

To use a measure try using SUMX

 

Measure = CALCULATE(SUMX('Table';'Table'[Litre]*'Table'[Concentration]*15,99); FILTER('Table';'Table'[result]="Fail"))

I have a further refinement that I could use your expertise with.  I've used the formula you provided:

 

Magna Losses = CALCULATE(SUMX('table',table[Litre]*table[Concentration]*15.99), FILTER('table',table[result]="Fail"), FILTER('table',table[Fuel Type]="Magna"))

 

But the final results that I am trying to get are presented here in a using mathematic logic (I still need to filter in the formula above):

 

(table[Litre] - (table[Litre] * table[Concentration])*15.99)

 

How would I translate that into a DAX statement?

 

Thanks, in advance!

vrs
Frequent Visitor

in the expr of SUMX(table, expr), you can put any mathematic logic you need.

 

in the same formula change the SUMX expression to

SUMX('Table';'Table'[Litre]-('Table'[Litre] * 'Table'[Concentration]*15,99))

 

 

hope this helps 🙂

Greg_Deckler
Super User
Super User

Try this:

 

Measure = CALCULATE(SUM((table[Litre]*table[concentration])*15.99),table[result]="Fail",)

The issue here is that if this is a measure, you need to do some kind of aggregation. Another way to do this would be to create a calculated column like this:

 

Column = IF(table[result]="Fail",table[Litre]*table[concentration]*15.99,0)

Returns your caculation if the result is "Fail" or else returns 0.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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