Forum Discussion
GiaD30
Helper II
1 year agoHelp 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...
- 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 ) )
GiaD30
Helper II
1 year agodanextian thank you so much for the solution, it worked indeed. The only question I still have, is it possible , to see the value for the final measure on the same row as gross salary? I am asking this, cause i don't always have the gross salary value added on the first row, from the 3, 4 etc names I have and I wouls like to keep consistency in the table.
danextian
Super User
1 year agoHi 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
)
)