cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
webportal
Impactful Individual
Impactful Individual

Using a Boolean expression with CALCULATE

 

Can someone explain me why this expression of a calculated measure works:

 

Measure = CALCULATE(SUM(Facts[Turnover]);FILTER('Facts';'Facts'[UnitPrice]>=50))

 Whereas this one doesn't:

 

Measure = CALCULATE(SUM(Facts[Turnover]);'Facts'[UnitPrice]>=50)

I know CALCULATE can use a Boolean expression or a table expression that defines a filter, but isn't the second expression using a Bolean condition:

'Facts'[UnitPrice]>=50

 

1 ACCEPTED SOLUTION

This is correct. No measure or CALCULATE expression, unless you write a full FILTER expression around it.

View solution in original post

9 REPLIES 9
KHorseman
Community Champion
Community Champion

In what sense does the second formula "not work"? It appears to work fine in my test.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




webportal
Impactful Individual
Impactful Individual

Hello,

 

I get the error:

Capturar.JPG

 

 

 

This means something like: "A CALCULATE function was used in a TRUE/FALSE expression as a table filter. This is not allowed".

And this message gets me even more confused.

 

However, the following function works perfectly:

Capturar2.JPG


Are you adding that formula as a measure or a column?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




webportal
Impactful Individual
Impactful Individual

As a measure.

If 'Facts'[UnitPrice] is a calculated column, this expression

Measure = CALCULATE(SUM(Facts[Turnover])
;'Facts'[UnitPrice]>=50
)

is just a shortcut for:

Measure = CALCULATE(SUM(Facts[Turnover])
;FILTER( ALL('Facts'[UnitPrice])
;'Facts'[UnitPrice]>=50
)
)

 If 'Facts'[UnitPrice] is a measure, however, you will get an error message about CALCULATE not being allowed in a filter expression expression (of a CALCULATE expression).

 

Is it what is happening here?

Yes, 'Facts'[UnitPrice] is a measure.

Then you have your answer. Man Happy

Ok, so the answer is I can't use a calculated measure in CALCULATE but I can use in FILTER function, correct?

This is correct. No measure or CALCULATE expression, unless you write a full FILTER expression around it.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors