Forum Discussion

GiaD30's avatar
GiaD30
Icon for Helper II rankHelper II
1 year ago
Solved

Help with a DAX measure

Hello everyone and Happy New Year,   I need your help, please, with a situation.   I have the below table, with name, gross salary, toys and total money spent. Net salary, Cars benefit, Books be...
  • danextian's avatar
    danextian
    1 year ago

    Hi GiaD30 

    You can instead check whether Gross salary is blank in the current row

    Final measure =
    VAR _fm =
        -- Calculate the net salary after deducting specific benefits for each Name.
        [Net Salary]
            - CALCULATE (
                -- Sum of benefits for Cars, Books, and Games
                [Cars benefit] + [Books benefit] + [Games benefit],
                -- Remove all filters except for the Name column
                ALLEXCEPT ( test, test[Name] )
            )
    RETURN
        -- Check if there is more than one value in the Name column in the current context
        IF (
            NOT ( HASONEVALUE ( test[Name] ) ),
            -- If there are multiple names, return the calculated _fm
            _fm,
            -- Otherwise, check if the Gross salary is not blank
            IF (
                NOT ( ISBLANK ( SELECTEDVALUE ( test[Gross salary] ) ) ),
                _fm
            )
        )