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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
pbi_user_47
New Member

minimum distance of a customer then aggregated to show how many customers fall in each bucket

first timer. I am trying to do what feels like a simple aggregation. I have a list of customers and their distance to candy stores. I want to summarize the number of customers by their distance to the closest store. 

 

pbi_user_47_0-1757096736769.png

 

in SQL it looks like this: 

select
  closest_store
  ,COUNT(DISTINCT customerID) AS customers
from (select
        customerID,
        min(dist_miles_bins) as closest_store
      from table1
      where
        store_item_type = 'CANDY'
        and store_name IN ('candystore','sugarrush')
      group by all
    ) a
 group by all
 order by closest_store
 
My problem is that when I go to plot this in a clustered bar graph I cannot get the axis to show the closest_store on the x-axis and the distinct count of customers on the Y-axis. please help and show me how I am missing a simple one line solution. thank you.
1 ACCEPTED SOLUTION
MarkLaf
Super User
Super User

A measure solution.

 

Cust Count by Min Miles = 
VAR _milesInFilterContext = VALUES( Table1[Miles Away] )
RETURN
COUNTX( 
    VALUES( Table1[customerID] ), 
    VAR _minMileByCust = CALCULATE( MIN( Table1[Miles Away] ), ALL( Table1[Miles Away] ) )
    RETURN
    IF( _minMileByCust IN _milesInFilterContext, 0 )
)

 

MarkLaf_3-1757107637887.png

 

Formatting: continuous x-axis with title/value labels off + custom format data labels

 

 

View solution in original post

2 REPLIES 2
MarkLaf
Super User
Super User

A measure solution.

 

Cust Count by Min Miles = 
VAR _milesInFilterContext = VALUES( Table1[Miles Away] )
RETURN
COUNTX( 
    VALUES( Table1[customerID] ), 
    VAR _minMileByCust = CALCULATE( MIN( Table1[Miles Away] ), ALL( Table1[Miles Away] ) )
    RETURN
    IF( _minMileByCust IN _milesInFilterContext, 0 )
)

 

MarkLaf_3-1757107637887.png

 

Formatting: continuous x-axis with title/value labels off + custom format data labels

 

 

YEP. SAVED MY WEEKEND. TYFYS MARK.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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