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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

grouping and segmenting to count the number of rows in power bi using dax

I have one table named survey that contains rating numbers. I want to group these numbers based on certain conditions. For this, I have created another table named SupportTable. Based on the min and max from this table I want to group the rating. For this, I tried the following code but didn't get the desired result. I want to get the result in measure( Numbers Per Group). What I am doing wrong here?

 

Total number of feedback = COUNTROWS(Survey) #counts no of rows in survey table

Numbers Per Group = CALCULATE([Total number of feedback],

                        FILTER(VALUES(Survey[Rating]),

                           COUNTROWS(

                               FILTER('SupportTable',

                                  Survey[Rating]>= 'SupportTable'[Min]

                                  && Survey[Rating]< 'SupportTable'[Max]))

                                    >0))

question.jpg

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Anonymous 

Numbers Per Group =
VAR min_ = SELECTEDVALUE ( 'SupportTable'[Min] )
VAR max_ = SELECTEDVALUE ( 'SupportTable'[Max] )
RETURN
    COUNTROWS ( FILTER ( Survey, Survey[Rating] >= min_ && Survey[Rating] < max_ ) )

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , You have to use your independent table in measures and also need to push row context.

refer to my video on a similar topic can help you

https://www.youtube.com/watch?v=CuczXPj0N-k

File at : https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626

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
AlB
Community Champion
Community Champion

Hi @Anonymous 

Numbers Per Group =
VAR min_ = SELECTEDVALUE ( 'SupportTable'[Min] )
VAR max_ = SELECTEDVALUE ( 'SupportTable'[Max] )
RETURN
    COUNTROWS ( FILTER ( Survey, Survey[Rating] >= min_ && Survey[Rating] < max_ ) )

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

amitchandak
Super User
Super User

@Anonymous , refer if my video on similar topic can help you

https://www.youtube.com/watch?v=CuczXPj0N-k

File at : https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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