Forum Discussion
Anonymous
2 years agoNot applicable
dax
p1m = CALCULATE( DISTINCTCOUNT(PSR[customer_code]), FILTER( VALUES(PSR[customer_code]), [sum of ret] > 0 ) ) this is a measure that calculates distinct customer...
- Anonymous2 years ago
Hi Anonymous ,
I suggest you to create a "DimDate" table to help calculation.
DimDate = VAR _CALENDAR = CALENDARAUTO() RETURN ADDCOLUMNS ( _CALENDAR, "Year", YEAR ( [Date] ), "Month", MONTH ( [Date] ), "MonthName", FORMAT ( [Date], "MMMM" ), "RANKX", RANKX ( _CALENDAR, YEAR ( [Date] ) * 100 + MONTH ( [Date] ),, ASC, DENSE ) )Measure:
Sum 3 month count = VAR _SUMMARIZE = SUMMARIZE ( ALL ( DimDate ), DimDate[Year], DimDate[MonthName], DimDate[RANKX], "P1M", [p1m] ) RETURN SUMX ( FILTER ( _SUMMARIZE, [RANKX] > MAX ( DimDate[RANKX] ) - 3 && [RANKX] <= MAX ( DimDate[RANKX] ) ), [P1M] )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Kishore_KVN
2 years agoSolution Sage
Hello Anonymous ,
Firstly create a calendar table and create relationship with your fact table.
Then use below calculation by modifying table names as per your data.
Cal_Measure =
Var CM = CALCULATE(DISTINCTCOUNT(PSR[customer_code]), Filter(Calendar_Table, 'Calendar_Table'[Month] = Month(Today())))
Var PM = CALCULATE(DISTINCTCOUNT(PSR[customer_code]), Filter(Calendar_Table, 'Calendar_Table'[Month] = Month(Today())-1))
Var PPM = CALCULATE(DISTINCTCOUNT(PSR[customer_code]), Filter(Calendar_Table, 'Calendar_Table'[Month] = Month(Today())-2))
Return
CM+PM+PPM
If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!
- Anonymous2 years agoNot applicable
not displaying anything