Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

DAX - Substract

Dear all,

 

I'm trying to create a DAX formula to subtract the MAX from the MIN but without taking into consideration the value O in the column Kilometerstand. I can't filter the values without 0 as in the data table I'm working with there are other values which are not zero.

 

 

MeasureTable

Data table

Thanks in advance fro your inputs.

 

Best regards

  • Try

    My Measure =
    IF (
        2022 = 0,
        1,
        MAX ( '2022'[Kilometerstand] )
            - CALCULATE ( MIN ( '2022'[Kilometerstand] ), '2022'[Kilometerstand] > 0 )
    )
    

4 Replies

  • Try

    My Measure =
    IF (
        2022 = 0,
        1,
        MAX ( '2022'[Kilometerstand] )
            - CALCULATE ( MIN ( '2022'[Kilometerstand] ), '2022'[Kilometerstand] > 0 )
    )
    
    • Anonymous's avatar
      Anonymous
      Not applicable

      johnt75Is there a possibility to that the calculation follows a date filter ?

       

      Example: I would like to filter on different months and then get the calculation performed just on this values. Would I need to adjust the Dax formula

      • johnt75's avatar
        johnt75
        Super User

        As long as there is an active relationship from the date table to the 2022 table then it should just work, I don't think any changes are needed.

  • Anonymous's avatar
    Anonymous
    Not applicable

    johnt75thanks a lot. It's working like I imagined.