cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

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
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.

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.

4 REPLIES 4
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.

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.

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))

Helper II

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

Post Prodigy

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.

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors