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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
san17680
Helper II
Helper II

calculate and/or conditions

Hi,

 

I am trying to make sense of and/or conditons in calculate.

 

This works calculate multiple table or conditions = =CALCULATE([TOTAL_SALES],'Product'[Color]="Red",'Calendar'[Year]=2017)

 

the below does not

 = CALCULATE([TOTAL_SALES],'Product'[Color]="Red" && 'Calendar'[Year]=2017)
 
I know 
 
what is the difference between the two.
 
Thanks
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @san17680 ,

 

The second formula uses the && operator to combine the same two conditions. However, this is not a valid syntax in DAX. 

Power BI Desktop also prompts this when I reproduce the error. You can check the screenshot below.

vstephenmsft_0-1691653544119.png

            

 

                                                                                                                                             

Best Regards,

Stephen Tao

 

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

View solution in original post

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @san17680 ,

 

The second formula uses the && operator to combine the same two conditions. However, this is not a valid syntax in DAX. 

Power BI Desktop also prompts this when I reproduce the error. You can check the screenshot below.

vstephenmsft_0-1691653544119.png

            

 

                                                                                                                                             

Best Regards,

Stephen Tao

 

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

eliasayyy
Super User
Super User

in the ccalculate function,
you first type the expresion and the filters 

when you first use " ," as the first filter and type in color = "red , you are filtering the color table and therefor cant use && , so you need to apply more than one filter 

however if you have a relationship between both ,

try 
CALCULATE([TOTAL_SALES],FILTER('Product','Product'[Color]="Red" && 'Calendar'[Year]=2017))

 CALCULATE([TOTAL_SALES],FILTER('Product','Product'[Color]="Red" && 'Calendar'[Year]=2017)) this wont work because there is no filter table for this conditionn  'Calendar'[Year]=2017

 

my question is isn't this  CALCULATE([TOTAL_SALES],'Product'[Color]="Red",'Calendar'[Year]=2017

same as CALCULATE([TOTAL_SALES],'Product'[Color]="Red", && 'Calendar'[Year]=2017

sergej_og
Super User
Super User

The reason for this behaviour are the conditions you define.
One comes from table 'Product', other comes from table 'Calendar'.
Different tables are separated by comma not by &&.
If you have data from same table e.g. 'Product' you can use && defining conditions. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.