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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mplotegher
New Member

Comparing 2 sets of data based on slicer selections

Hi community, need some help to find a solution to my challenge.

Have a table which lists all customers of a territory and also how much each distributor sold to each of the customers in a particular timeline.

Expected outcome: for any multi-selection of 2 or more distributors, a NEW MEASURE (%) will tells me what is the percentage of customers where all the selected distributors reported any sales in the timeline.

Example: considering the table below, if i wanted to compare Dist A and Dist B, the result will be that both reported sales together to only 2 customers (1 and 7) out of the 7, so Measure will be: 28.6%
If selected Dist B and C, would be 3 customers (1, 2 and 6), out of the 7, so 42.9%.

CustSales Dist ASales Dist BSales Dist C
112488
20556
378032
40560
58036
609893
736900

 

Any idea on how I could translate that into Power BI?

 

Thanks!

1 ACCEPTED SOLUTION
anmolmalviya05
Super User
Super User

Hi @mplotegher

Firsly Create a Distributors Slicer

  • Ensure that you have a Distributors table with a list of distributors (Dist A, Dist B, Dist C).
  • Add a slicer for distributors.

Then Create the below measure

Percentage_Customers_Selected_Dist =
VAR SelectedDists = VALUES('Distributors'[Distributor]) -- Get selected distributors
VAR TotalCustomers = DISTINCTCOUNT('SalesTable'[Cust]) -- Count total unique customers

VAR CustomersWithAllSales =
CALCULATE(
DISTINCTCOUNT('SalesTable'[Cust]),
FILTER(
'SalesTable',
SUMX(
SelectedDists,
LOOKUPVALUE(
'SalesTable'[Sales],
'SalesTable'[Distributor], [Distributor],
'SalesTable'[Cust], 'SalesTable'[Cust]
)
) > 0 -- Ensure all selected distributors have sales
)
)

RETURN
DIVIDE(CustomersWithAllSales, TotalCustomers, 0)

 

After it, 

  • Add the measure to a card visual to display the percentage.
  • Use the slicer to select multiple distributors dynamically.

 

 

View solution in original post

1 REPLY 1
anmolmalviya05
Super User
Super User

Hi @mplotegher

Firsly Create a Distributors Slicer

  • Ensure that you have a Distributors table with a list of distributors (Dist A, Dist B, Dist C).
  • Add a slicer for distributors.

Then Create the below measure

Percentage_Customers_Selected_Dist =
VAR SelectedDists = VALUES('Distributors'[Distributor]) -- Get selected distributors
VAR TotalCustomers = DISTINCTCOUNT('SalesTable'[Cust]) -- Count total unique customers

VAR CustomersWithAllSales =
CALCULATE(
DISTINCTCOUNT('SalesTable'[Cust]),
FILTER(
'SalesTable',
SUMX(
SelectedDists,
LOOKUPVALUE(
'SalesTable'[Sales],
'SalesTable'[Distributor], [Distributor],
'SalesTable'[Cust], 'SalesTable'[Cust]
)
) > 0 -- Ensure all selected distributors have sales
)
)

RETURN
DIVIDE(CustomersWithAllSales, TotalCustomers, 0)

 

After it, 

  • Add the measure to a card visual to display the percentage.
  • Use the slicer to select multiple distributors dynamically.

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.