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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

How to Run Excel Percentile and IF Calculation in BI?

Need help with translating Percetile and IF formulaes into BI. I use these in excel

Total Cost is a total of each row sales

Total Cost % is = Cell Value / Total Of Column. which is then % of total cost. 

The ABC column runs an IF and Percentile to select top 80% = A, 10-20% = B, 2-10% = C, less than 1% = D

Example.PNG

 

2. Precentile formuale works on =IF(S2>=PERCENTILE(S:S,0.8)=TRUE,"A","0") , 

 

It works in excel but I am stuck getting this to work in BI. 

I cannot get a text return on the IF, am only getting a numeric return.

 

Would really appreciate any help

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

 

Please use the below measure. Have used some dummy value.

 

Table Name = Table6

 

 

Sum of Values = SUM(Table6[Values])
 
%Sum of Values = DIVIDE([Sum of Values], CALCULATE([Sum of Values],ALL(Table6)))
 

 

 

Rate =
VAR _2P =
    PERCENTILEX.INC (
        ALL ( table6 ),
        Table6[%Sum of Values],
        .02
    )
VAR _10P =
    PERCENTILEX.INC (
        ALL ( table6 ),
        Table6[%Sum of Values],
        .10
    )
VAR _20P =
    PERCENTILEX.INC (
        ALL ( table6 ),
        Table6[%Sum of Values],
        .20
    )
VAR _80P =
    PERCENTILEX.INC (
        ALL ( table6 ),
        Table6[%Sum of Values],
        .80
    )
RETURN
    SWITCH (
        TRUE (),
        Table6[%Sum of Values] > _80P"A",
        Table6[%Sum of Values] > _20P
            && Table6[%Sum of Values] < _10P"B",
        Table6[%Sum of Values] >= _10P
            && Table6[%Sum of Values] < _2P"C",
        Table6[%Sum of Values] <= _2P"D",
        "Not Defined"
    )


1.jpg

 

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!

View solution in original post

7 REPLIES 7
Greg_Deckler
Super User
Super User

Perhaps this will help: https://community.powerbi.com/t5/Community-Blog/Excel-to-DAX-Translation/ba-p/1060991



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg,

 

Thank you, that has been a great guide for me. 

nandukrishnavs
Super User
Super User

@Anonymous 

 

Total Cost % = Table1[Total Cost]/SUM(Table1[Total Cost])

Then apply if condition to categorize into A, B, C

Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

Anonymous
Not applicable

Thanks for your time to respond on this.

When running the percentile and IF calculation it will not output a text

 

For example If percentile <0.8,"A", this is where it will not accept the A, but it will accept numbers. 

 

Hi @Anonymous ,

 

 

Please use the below measure. Have used some dummy value.

 

Table Name = Table6

 

 

Sum of Values = SUM(Table6[Values])
 
%Sum of Values = DIVIDE([Sum of Values], CALCULATE([Sum of Values],ALL(Table6)))
 

 

 

Rate =
VAR _2P =
    PERCENTILEX.INC (
        ALL ( table6 ),
        Table6[%Sum of Values],
        .02
    )
VAR _10P =
    PERCENTILEX.INC (
        ALL ( table6 ),
        Table6[%Sum of Values],
        .10
    )
VAR _20P =
    PERCENTILEX.INC (
        ALL ( table6 ),
        Table6[%Sum of Values],
        .20
    )
VAR _80P =
    PERCENTILEX.INC (
        ALL ( table6 ),
        Table6[%Sum of Values],
        .80
    )
RETURN
    SWITCH (
        TRUE (),
        Table6[%Sum of Values] > _80P"A",
        Table6[%Sum of Values] > _20P
            && Table6[%Sum of Values] < _10P"B",
        Table6[%Sum of Values] >= _10P
            && Table6[%Sum of Values] < _2P"C",
        Table6[%Sum of Values] <= _2P"D",
        "Not Defined"
    )


1.jpg

 

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!

Anonymous
Not applicable

Hi Harsh

 

Thank you very much

Works well thank you

 

Thanks 

Johnny

@Anonymous ,

 

You are Welcome.

 

Do Mark with @ incase you face any issues

 

Regards,

Harsh Nathani

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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