Monday, August 22, 2022

Power BI Calculate DAX Function

In Power BI, I use CALCULATE in almost all measure.

Syntax: CALCULATE(<expression>[, <filter1> [, <filter2> [, …]]])


Here is an example of the CALCULATE function where is specify which Date relationship I want the calculation to use when determine the total number of unique Air Tickets, excluding Refunded and Voided tickets.

Air Tickets = CALCULATE(DISTINCTCOUNTNOBLANK('Air Ticket'[Ticket Number])
, USERELATIONSHIP('Calendar'[Date],'Air Ticket'[Issued Date])
, KEEPFILTERS('Air Ticket'[Ticket Status] <> "Refund")
, KEEPFILTERS('Air Ticket'[Ticket Status] <> "Voided")
)

Source: https://learn.microsoft.com/en-us/dax/calculate-function-dax