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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
AnkitaaMishra
Super User
Super User

Need help to replicate Excel formula using DAX

Hi All, 
I am doing few calculation in excel which I would like to replicate using DAX in Power BI : 
Below is the raw table in excel : 

AccountAccount Means
Account 189.30951472
Account 284.44998398
Account 348.44260215
Account 476.18483461
Account 56.54566581
Account 680.57958041
Account 780.82168525
Account 857.33064507
Account 917.96370662
Account 1084.11002185
Account 1131.05410716
Account 1280.00578869
Account 1391.57964664
Account 1450.0811584
Account 1591.73717523
Account 1631.5117545
Account 1753.57517991
Account 181.5190093
Account 1990.34303699
Account 2085.8063106
Account 2120.31086152
Account 2230.34881251
Account 2350.28171327
Account 2454.11314484
Account 2584.17643827
Account 2620.89591916
Account 2711.00972825
Account 2881.47025708
Account 2978.22208867
Account 3075.05752564

 

Next I am calculating percentile and getting below result as Percentile table (using Percentile.INC DAX formula in Power BI) : 

PercentilePercentile Value
0.058.55449391
0.117.26830879
0.1520.51563169
0.228.45823384
0.2531.16851899
0.343.36334786
0.3550.11124163
0.452.25779326
0.4554.27401985
0.566.19408536
0.5576.12846916
0.678.93556868
0.6580.49351165
0.781.0162568
0.7583.45008065
0.884.23114741
0.8585.33159628
0.989.41286695
0.9591.0231723
191.73717523

 

After that below is the Formula I am using which I am unable to replicate in DAX for the highlighted row in snapshot :
=AVERAGEIFS($D$5:$D$34,$D$5:$D$34,"<"&INDEX($H$5:$H$24,MATCH($L5,$G$5:$G$24,0)))

WhatsApp Image 2025-01-08 at 14.41.00.jpeg

 

 


Thanks,
Ankita

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @AnkitaaMishra ,

 

Not sure if the value you show in the last image are correct however this can be done in the following way:

  • Create a separate table for the percentile then add the folllowing measures:
Percentile value = PERCENTILE.INC('Accounts'[Account Means], SELECTEDVALUE('Percentile'[Percentile]))

Average Value = 
 var PercentileTotal = [Percentile value]
 var temp_table = FILTER('Accounts', 'Accounts'[Account Means] < PercentileTotal)
 Return
  AVERAGEX(temp_table, 'Accounts'[Account Means])

 

If you want to have a third table with the benchmark redo the Average Value to:

 

Average Value benchmar = 
 var PercentileTotal = CALCULATE([Percentile value] , Percentile[Percentile] = SELECTEDVALUE('Percentile Benchmark'[Percentile Benchmark]))
 var temp_table = FILTER('Accounts', 'Accounts'[Account Means] < PercentileTotal)
 Return
  AVERAGEX(temp_table, 'Accounts'[Account Means])

MFelix_0-1736330631494.png

See file attach

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Hi @AnkitaaMishra ,

 

Not sure how you have the rest of the model but you should change the Percentile calculation to something similar to this:

Percentile value = CALCULATE(PERCENTILE.INC('Accounts'[Account Means], SELECTEDVALUE('Percentile'[Percentile])), ALLSELECTED(Accounts[Account]))

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

5 REPLIES 5
MFelix
Super User
Super User

Hi @AnkitaaMishra ,

 

Not sure if the value you show in the last image are correct however this can be done in the following way:

  • Create a separate table for the percentile then add the folllowing measures:
Percentile value = PERCENTILE.INC('Accounts'[Account Means], SELECTEDVALUE('Percentile'[Percentile]))

Average Value = 
 var PercentileTotal = [Percentile value]
 var temp_table = FILTER('Accounts', 'Accounts'[Account Means] < PercentileTotal)
 Return
  AVERAGEX(temp_table, 'Accounts'[Account Means])

 

If you want to have a third table with the benchmark redo the Average Value to:

 

Average Value benchmar = 
 var PercentileTotal = CALCULATE([Percentile value] , Percentile[Percentile] = SELECTEDVALUE('Percentile Benchmark'[Percentile Benchmark]))
 var temp_table = FILTER('Accounts', 'Accounts'[Account Means] < PercentileTotal)
 Return
  AVERAGEX(temp_table, 'Accounts'[Account Means])

MFelix_0-1736330631494.png

See file attach

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hello @MFelix ,
Thanks for your reply, This solution is working for me.

I need additional help here. 
Actually I have multiple slicers added in the report which are not driving these percentile value, its coming constant. I checked its not relationship issue. for example If any year is selected then also the values are same.

 

WhatsApp Image 2025-01-13 at 12.58.40.jpeg

Is there any way we could calculate this dynamically?

Thanks,
Ankita

Hi @AnkitaaMishra ,

 

Not sure how you have the rest of the model but you should change the Percentile calculation to something similar to this:

Percentile value = CALCULATE(PERCENTILE.INC('Accounts'[Account Means], SELECTEDVALUE('Percentile'[Percentile])), ALLSELECTED(Accounts[Account]))

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



AnkitaaMishra
Super User
Super User

Hi @danextian , thanks for your reply.
I am using Percentile excel formula to calculate second table

danextian
Super User
Super User

Hi @AnkitaaMishra 

 

What specific formula did you use to get the second table? And is that the result of a calculated table. I am asking because I can't seem to replicate the result using PERCENTILE.INC on your sample data.










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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