Forum Discussion
mojo_flex
2 years agoNew Member
Conditional measure to avoid sum duplicates
Hi, I would like some help creating a measure that avoids summing duplicates and incorporates some conditional logic. I'm very new to DAX and so it may be that what I am attempting is impossible...
- 2 years ago
mojo_flex , one of the ways to achieve this is to use the virtual tables you've created:
conditional_sum = VAR t_A = SUMMARIZE ( T, T[DATE], T[CAT], T[Value] ) VAR t_BC = SUMMARIZE ( T, T[CAT], T[VALUE] ) VAR current_cat = SELECTEDVALUE ( T[Cat] ) RETURN IF ( current_cat = "A", SUMX ( t_A, [Value] ), SUMX ( t_BC, [Value] ) )Is this what you want to achieve?
- ERD2 years agoCommunity Champion
mojo_flex , one of the ways to achieve this is to use the virtual tables you've created:
conditional_sum = VAR t_A = SUMMARIZE ( T, T[DATE], T[CAT], T[Value] ) VAR t_BC = SUMMARIZE ( T, T[CAT], T[VALUE] ) VAR current_cat = SELECTEDVALUE ( T[Cat] ) RETURN IF ( current_cat = "A", SUMX ( t_A, [Value] ), SUMX ( t_BC, [Value] ) )Is this what you want to achieve?
- mojo_flex2 years agoNew Member
Answers my question perfectly. Thank you for taking the time to help me.
I was wondering if splitting my table was going to be neccessary as I wasn't aware of the virtual table function. I really appreciate the pointers!