Forum Discussion
Anonymous
7 years agoNot applicable
Help needed for DAX solution
Hi, I'm facing a challenge on a DAX measure. Sample data as below with 3 tables (Fact, dim_week, dim_cust). I will calculate the Best Week of each customer 1st, it can be hardcoded as below (in rea...
- 7 years ago
Anonymous try following, I'm sure there is going to be another elegant way but don't have energy right now to look for it, but I think for now this will do.
Customer Count by Week = VAR _customerWeek = SUMMARIZE( Customer, Customer[Customer], "Week", [Best Week] ) RETURN CALCULATE( DISTINCTCOUNT( Sales[Customer] ), INTERSECT( SELECTCOLUMNS( Sales, "Customer", Sales[Customer], "Week", [Week] ), __customerWeek ) ) - Anonymous7 years ago
parry2k Excellent, it works. Thank you very much.
parry2k
7 years agoSuper User
Anonymous try following, I'm sure there is going to be another elegant way but don't have energy right now to look for it, but I think for now this will do.
Customer Count by Week =
VAR _customerWeek = SUMMARIZE( Customer, Customer[Customer], "Week", [Best Week] )
RETURN
CALCULATE(
DISTINCTCOUNT( Sales[Customer] ),
INTERSECT(
SELECTCOLUMNS( Sales, "Customer", Sales[Customer], "Week", [Week] ),
__customerWeek
)
)Anonymous
7 years agoNot applicable
parry2k Excellent, it works. Thank you very much.