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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
E_K_
Helper III
Helper III

I'm trying to get percentile ranks per client

Please help troubleshoot my code. I feel like it is very close but it doesn't like the "ClientswithIncidents variable at the last step

Percentile per Month =
VAR SelectedMonth = MAX('Incidents'[Start Time])
VAR SelectedClient = SELECTEDVALUE('Incidents'[Client])
RETURN
    IF(
        ISBLANK(SelectedMonth) || ISBLANK(SelectedClient),
        BLANK(),
        VAR IncidentCount =
            CALCULATE(
                [Incident Count],
                'Incidents'[Client] = SelectedClient,
                YEAR('Incidents'[Start Time]) = YEAR(SelectedMonth),
                MONTH('Incidents'[Start Time]) = MONTH(SelectedMonth)
            )
        VAR ClientIncidentCounts =
            ADDCOLUMNS(
                GROUPBY(
                    FILTER(
                        'Incidents',
                        YEAR('Incidents'[Start Time]) = YEAR(SelectedMonth)&&
                        MONTH('Incidents'[Start Time]) = MONTH(SelectedMonth)
                    ),
                    'Incidents'[Client],
                    "Total Incidents", [Incident Count]
                ),
                "IncidentCount", [Total Incidents]
            )
            VAR ClientswithIncidents = FILTER(ClientIncidentCounts, [Incident Count]<> BLANK())
            VAR PercentileRank =
            DIVIDE(RANKX(
                                    ClientswithIncidents,[Total Incidents],,ASC,Dense)-1,
                                    DISTINCTCOUNT('Incidents'[Client]))
                   
                           RETURN
            PercentileRank
1 REPLY 1
amitchandak
Super User
Super User

@E_K_ ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

I think Window function can help here, refer my example

Power BI Window function- Pareto Analysis, 80% of sales, Order by on Measure: https://www.youtube.com/watch?v=UVxiLc_AzSs

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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