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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Rockyalex
Regular Visitor

Counting Data on ranked Dataset with filters

Hi, I am trying to show count of distinct AgeGroup-ID for each country-ID from the top 20% of Data set.

so first i created Rank as 

Rank = RANKX(
ALLSELECTED('FACT-Population'[Country-ID],'FACT-Population'[AgeGroup-ID],'FACT-Population'[Gender]),
calculate(sum('FACT-Population'[Population])),
,
DESC,
Dense
)
below shows what i have created. based on the country selection or Gender selection i get the Data ranked correctly
Rockyalex_1-1659175463493.png

 

I want to show Country and distinct count of AgeGroup-ID as a matrix for Rank <20 (ie. top 20% of my dataset) and also when i filter on Country ID or Gender the calcualtion should be applied on the filtered dataset.
The output i am expecting should look like
Rockyalex_0-1659176261219.png

 

 



 
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Rockyalex 

 

You can try the following methods.

Measure:

CountAgeGroup-ID =
CALCULATE (
    DISTINCTCOUNT ( 'FACT-Population'[AgeGroup-ID] ),
    FILTER (
        ALL ( 'FACT-Population' ),
        [Rank] <= 20
            && [Country-ID] = SELECTEDVALUE ( 'FACT-Population'[Country-ID] )
    )
)

vzhangti_0-1659427066569.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @Rockyalex 

 

You can try the following methods.

Measure:

CountAgeGroup-ID =
CALCULATE (
    DISTINCTCOUNT ( 'FACT-Population'[AgeGroup-ID] ),
    FILTER (
        ALL ( 'FACT-Population' ),
        [Rank] <= 20
            && [Country-ID] = SELECTEDVALUE ( 'FACT-Population'[Country-ID] )
    )
)

vzhangti_0-1659427066569.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-zhangti ,

 

Thank you it worked perfectly. 

what if i want to see the Details of AgeGroup id under the Country in the Matrix ? currenly you cannot expand the Country ID to see what AgeGroup ID's are in it (currently .

Rockyalex_0-1659467615283.png

 

 

Thanks & Regards,

Alex

 

 

amitchandak
Super User
Super User

@Rockyalex , Use rank in the visual level filter of create a measure like

 


Total Filter population = Sumx(filter(
Addcolumns( Summarize('FACT-Population'[Country-ID],'FACT-Population'[AgeGroup-ID],'FACT-Population'[Gender]),"_1"
calculate(sum('FACT-Population'[Population])), "_2",m [Rank]) ,[_2]<= 20) ,[_1])

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.