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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
scurrp
Frequent Visitor

DAX Calculatetable then filter

Hi, 
I'm trying to calculate the count of records that fall within range criteria.

My approach was to calculate the table of results that I need to count.
This is the CustomerID and the Visit%. Visit% this, in turn, is a measure of actual vs plan.
Then I have a junk dimension dimCustomerVisitCategory, with min and max range values.
The next step is where I get stuck.

I want to count the rows of the calculated table where the visit % is between the min and max range values.

The problem I'm finding is that 

1- all records are getting allocated to 1 category 

2 - the number of records is higher than expected ie 67 vs 8.

 

Thanks in advance for any assistance.

 

 

 

xx = 
var IIS = ISINSCOPE(dimCustomerVisitCategory[Customer Visit Categories])
var Mn = MIN(dimCustomerVisitCategory[MinRange])
var Mx = Max(dimCustomerVisitCategory[MaxRange])
VAR CustVisitAvg =
 CALCULATETABLE (
 ADDCOLUMNS (
 SUMMARIZE ( fact_CustomerVisits, fact_CustomerVisits[CustomerID] ),
 "Customervisitpc", [Visit %]))

var CR = COUNTROWS( FILTER(CustVisitAvg,[Customervisitpc] >= mn && [Customervisitpc] < mx) )+0
return
Switch( true(),
IIS, CR
)

 

 


 image.png

2 REPLIES 2
amitchandak
Super User
Super User

@scurrp , I think you very similar to what I have done here

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I think my biggest problem was not naming the problem correctly.
I tried implementing the proposed solution, with some strange results.
Knowing the correct name of the problem I went to daxpatterns -dynamic segmentation and was able to implement that pattern successfully.
image.png

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 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.