Forum Discussion

bestevezdyb's avatar
bestevezdyb
Frequent Visitor
2 years ago
Solved

DAX SelectedValue With If

Good morning, I would like to understand how to solve a problem that apparently is getting complicated. I have created a metric that is NumberOfPizza = VAR _qty = COUNTROWS( order_details ) R...
  • bestevezdyb's avatar
    bestevezdyb
    2 years ago

    I think I have the solution

    SelectedValue =
     
    VAR _qty = [NumberOfPizza]
    RETURN
    IF(
        _qty = 0,
        CALCULATE(MAX(order_details[pizza_id]), REMOVEFILTERS(DimDate)),  -- Devuelve el valor de pizza_id si _qty es 0
        SELECTEDVALUE( order_details[pizza_id] )
    )