Skip to content

Comparing Customer Lists Virtually

>> Download the sample (Power BI)

This sample shows:

(i) Total customers per product, this year
(ii) Total customers per product, last year
(iii) The number of customers who bought both this year and last year

Common Customers =
COUNTROWS (
INTERSECT (
VALUES ( Sales_Table[Customer] ),
CALCULATETABLE (
VALUES ( Sales_Table[Customer] ),
DATESBETWEEN (
Calendar_Table[Date],
MIN ( Calendar_Table[Date] ) - 365,
MAX ( Calendar_Table[Date] ) - 365
)
)
)
)
Prior Year Customers =
COUNTROWS (
CALCULATETABLE (
VALUES ( Sales_Table[Customer] ),
DATESBETWEEN (
Calendar_Table[Date],
MIN ( Calendar_Table[Date] ) - 365,
MAX ( Calendar_Table[Date] ) - 365
)
)
)
This Year Customers =
COUNTROWS ( VALUES ( Sales_Table[Customer] ) )
Total Sales =
SUMX ( Sales_Table, Sales_Table[Quantity] * Sales_Table[Unit Price] )
Calendar_Table =
GENERATE (
CALENDAR ( DATE ( 2017, 1, 1 ), DATE ( 2019, 12, 31 ) ),
VAR currentDay = [Date]
VAR Day =
DAY ( currentDay )
VAR Month =
MONTH ( currentDay )
VAR Year =
YEAR ( currentDay )
RETURN
ROW ( "Day", day, "Month", month, "Year", year )
)