Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have made a table visual below:
For each Sales Representative I want to calculate no of distinct clients in a month which are not present in dates before the particular month.
I wrote following measure but I am getting blank values:
Solved! Go to Solution.
Hi @Anonymous
My Sample is as below. I create a relationship between Fact table and Date table by Date column.
Fact Table:
Date table:
Date =
ADDCOLUMNS (
CALENDARAUTO (),
"Year", YEAR ( [Date] ),
"Month", MONTH ( [Date] ),
"YearMonth",
YEAR ( [Date] ) * 100
+ MONTH ( [Date] ),
"MonthYear", FORMAT ( [Date], "MMM 'YY" )
)
Try this code.
New Clients =
VAR _RANGESTART = CALCULATE(MIN('Date'[Date]),ALLSELECTED('Date'))
VAR _RANGEEND = CALCULATE(MAX('Date'[Date]),ALLSELECTED('Date'))
VAR _CLIENT_LIST_BEFORE = CALCULATETABLE(VALUES('Table'[UniqueID]),FILTER(ALL('Table'),'Table'[Date]<_RANGESTART&&'Table'[Sales Representative]=MAX('Table'[Sales Representative])))
RETURN
CALCULATE(COUNT('Table'[UniqueID]),FILTER('Table',NOT('Table'[UniqueID] IN _CLIENT_LIST_BEFORE)))
Here I select my date slicer between 2021/03/01 to 2020/12/31.
Client in "A G" before date range are {C1,C2,C3}, so number of new client is 0.
Client in "C U" before date range are {C1,C2,C3,C5}, so number of new client (C4,C6) is 2.
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
My Sample is as below. I create a relationship between Fact table and Date table by Date column.
Fact Table:
Date table:
Date =
ADDCOLUMNS (
CALENDARAUTO (),
"Year", YEAR ( [Date] ),
"Month", MONTH ( [Date] ),
"YearMonth",
YEAR ( [Date] ) * 100
+ MONTH ( [Date] ),
"MonthYear", FORMAT ( [Date], "MMM 'YY" )
)
Try this code.
New Clients =
VAR _RANGESTART = CALCULATE(MIN('Date'[Date]),ALLSELECTED('Date'))
VAR _RANGEEND = CALCULATE(MAX('Date'[Date]),ALLSELECTED('Date'))
VAR _CLIENT_LIST_BEFORE = CALCULATETABLE(VALUES('Table'[UniqueID]),FILTER(ALL('Table'),'Table'[Date]<_RANGESTART&&'Table'[Sales Representative]=MAX('Table'[Sales Representative])))
RETURN
CALCULATE(COUNT('Table'[UniqueID]),FILTER('Table',NOT('Table'[UniqueID] IN _CLIENT_LIST_BEFORE)))
Here I select my date slicer between 2021/03/01 to 2020/12/31.
Client in "A G" before date range are {C1,C2,C3}, so number of new client is 0.
Client in "C U" before date range are {C1,C2,C3,C5}, so number of new client (C4,C6) is 2.
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , refer these two they can help
Customer Retention Part 5: LTD Vs Period Retention
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-5-LTD-and-PeriodYoY-Retention-is-only/ba-p/2114497
Customer Retention Part 1:
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/ba-p/1361529
file is attached after signature
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
24 | |
20 | |
15 | |
12 |
User | Count |
---|---|
55 | |
48 | |
43 | |
19 | |
19 |