Forum Discussion

Laura1996's avatar
Laura1996
Helper I
1 year ago
Solved

wrong measure total including if statement

I have a table "Komm", which looks like following. Right now my Total of "Factor final" is wrong and I cant wrap my head arount how to do it correctly:   Name Product Description Amount Unit...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Laura1996 ,

    Based on the description, try to use the following DAX formula.

    Faktor final = 
    VAR IsSpecificUnit = 
        SUMX(
            Komm, 
            IF(
                Komm[Unit] IN {"M", "GA", "L", "KG"}, 
                RELATED('Factor'[Factor]), 
                Komm[Amount] * RELATED('Factor'[Factor])
            )
        )
    RETURN 
        IF (
            HASONEVALUE(Komm[Name]),
            IsSpecificUnit,
            SUMX(
                Komm,
                IF (
                    Komm[Unit] IN {"M", "GA", "L", "KG"},
                    RELATED('Factor'[Factor]),
                    Komm[Amount] * RELATED('Factor'[Factor])
                )
            )
        )

    Then, select the Jack name.

     

    Best Regards,

    Wisdom Wu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.