Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Lucius98
Regular Visitor

Customer classification using virtual relationship

Hello.

 

I would like to build a map chart in which each bubble represents the number of customers per neighborhood,
classifying in the legend those I consider active (made at least one purchase per month) and
inactive (have not bought in the month, but have already bought in another time).

 

The measure used to calculate "Active Customers" is that one shown below.

 

Active Customers =
VAR Customers = VALUES(fSales[Customer ID])
RETURN
COUNTROWS(Customers)


The measure used to calculate "Inactive Customers" is that one shown below.

 

Inactive Customers =
VAR Month = EOMONTH(MAX(fSales[Date]),0)
VAR CurrentCustomers = VALUES(fSales[Customer ID])
VAR TotalCustomers =
CALCULATETABLE(
        VALUES(fSales[Customer ID]),
        FILTER(
               ALL('dCalendar'[Date]),
               'dCalendar'[Date] <= MAX('dCalendar'[Date])
         ),
         FILTER(
         ALL('dCalendar'[Date]),
         'dCalendar'[Date] < Month
         )
)
VAR InactiveCustomers = EXCEPT(TotalCustomers,CurrentCustomers)
RETURN
COUNTROWS(InactiveCustomers)

 

To build a way to create a visualization on the map, I tried to use an auxiliary
table such that it will relate to the customer base through a virtual relationship.
I tried doing this with the measures below.


Customer Classification =
var DateContext = SELECTEDVALUE('dCalendar'[Month/Year Class])
var DateMin =
CALCULATE(
      MIN(fSales[Date]),
      ALL('dCalendar')

)
var DataStart = YEAR(DataMin)*100+MONTH(DataMin)
var Test =
SWITCH(
        TRUE(),
        DateContext >= DataContext && [Active Customers] <> BLANK(), 1, //active clients
        DateContext >= DataContext && [Active Customers] = BLANK(), 2 //inactive clients
)
RETURN
Test


Medida 2 =
VAR Situation1 = MIN(dActiveInactive[Value 1])
VAR Situation2 = MAX(dActiveInactiveInativo[Value 2])
VAR Result =
CALCULATE(
          [Customer Classification],
          FILTER(
                 CROSSJOIN(
                          VALUES('dCalendar'[Month/Year]),
                          VALUES(dCustomers[Customer ID])
                 ),
                [Customer Classification] > Situation1 && [Customer Classification] <= Situation2
         )
)
RETURN
Result


However, I was unable to resolve the issue. Any idea how to solve this?

 

The intention is to do this without using a calculated column as it would leave the classification static
and ideally, the classification is dynamic.

 

Lucius98_1-1641315309609.png

This is the incorrect classification

 

 

1 REPLY 1
lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. Please show the expected outcome.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.