cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ted_kim Regular Visitor
Regular Visitor

I don't understand the restrictions of the CALCULATE (DAX).

Hello, community members.

 

I have been studying DAX function. ( URL : https://msdn.microsoft.com/query-bi/dax/calculate-function-dax)

There was something over an hour I couldn't understand.

 

There's nothing wrong right now, but I'm really curious about what that means.

 

-----------------------------------------------------------------------------------------------------------------------------------------

The following restrictions apply to Boolean expressions that are used as arguments:

  • The expression cannot reference a measure.

  • The expression cannot use a nested CALCULATE function.

  • The expression cannot use any function that scans a table or returns a table, including aggregation functions.

-------------------------------------------------------------------------------------------------------------------------------------------

 

Could anyone please give me examples or explanations?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Stachu Super Contributor
Super Contributor

Re: I don't understand the restrictions of the CALCULATE (DAX).

this reference is much more extensive

https://dax.guide/calculate/

https://www.sqlbi.com/articles/context-transition-and-filters-in-calculate/

 

regarding the boolean expression specifically (this is where the limitations are valid) e.g. check if color is red

CORRECT
CALCULATE(SUM(Table[Value]),Table[Color] = "Red")
CALCULATE(SUM(Table[Value]),LOWER(Table[Color]) = "red")
NOT CORRECT
Flag1 = IF(Table[Color] = "Red", TRUE,FALSE)
CALCULATE(SUM(Table[Value]),[Flag])

nested CALCUALTE is quite self explanatory, function that scans a table - my guess would be e.g. SUMX, FILTER (though I'm not sure about them)

please remember that instead of a boolean expression you can also pass a list of values - e.g. result of FILTER, DATESYTD, etc.

 

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

Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Highlighted
Stachu Super Contributor
Super Contributor

Re: I don't understand the restrictions of the CALCULATE (DAX).

this reference is much more extensive

https://dax.guide/calculate/

https://www.sqlbi.com/articles/context-transition-and-filters-in-calculate/

 

regarding the boolean expression specifically (this is where the limitations are valid) e.g. check if color is red

CORRECT
CALCULATE(SUM(Table[Value]),Table[Color] = "Red")
CALCULATE(SUM(Table[Value]),LOWER(Table[Color]) = "red")
NOT CORRECT
Flag1 = IF(Table[Color] = "Red", TRUE,FALSE)
CALCULATE(SUM(Table[Value]),[Flag])

nested CALCUALTE is quite self explanatory, function that scans a table - my guess would be e.g. SUMX, FILTER (though I'm not sure about them)

please remember that instead of a boolean expression you can also pass a list of values - e.g. result of FILTER, DATESYTD, etc.

 

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

Proud to be a Datanaut!

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 136 members 1,589 guests
Please welcome our newest community members: