Forum Discussion

Aaron_BI's avatar
Aaron_BI
Regular Visitor
5 years ago

Create Dynamic Groups That Can Filter Other Visuals

Hi,

 

I'm trying to achieve the following:

  1. Group customers based on their sales amount
  2. Customers should be assigned to a group dynamically based on a date filter
  3. When using this grouping in a visual, I want it to be able to filter the other visuals on a page when clicking on a specific group

 

I've been able to get 1 & 2 done, but I could use some help with 3. 

 

To illustrate, I have the following data model, where I simply have a table with a list of customers, and a table with a list of transactions with those customers.

 

In addition, I created a third table that isn't related to any other table which contains the groups I want to use: 

 

I've written the following measure that will sum the sales per customers, places each customer within one of these groups based on their total sales, and counts the number of customers per group. This measure also listens to a date filter I have on the page: 

 

Sales Per Group = 

/* Determine the upper and lower bound per group */
VAR LowerBound = MIN('Total Sales Group'[Lower Bound])
VAR UpperBound = MIN('Total Sales Group'[Upper Bound])

/* Calculate the total sales per customer */
VAR SalesPerCustomer = GROUPBY(Sales,Customers[ID],"TotalSales",SUMX(CURRENTGROUP(),Sales[Amount]))

/* Based on the table created in the previous step, determine which customers fall within the current group */
VAR CustomerPerGroup = 
FILTER(
    FILTER(
        SalesPerCustomer,
        [TotalSales] >= LowerBound
    ),
    [TotalSales] <= UpperBound
)

RETURN
COUNTROWS(CustomerPerGroup)

 

The last hurdle I need to get over is to get the visual in which I use this measure to filter the other visuals on the page. As seen on the image below, I've selected the 400 - 500 group, however the table still shows all customers, whereas I'd like it to show only the customers that fall in the 400 - 500 group.

 

 

Any input on how I can achieve this would be much appreciated!

 

Thanks,

Aaron