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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
volt26
Helper I
Helper I

DAX formula that returns columns based on subcolumn's value from smallest to highest

Hello!

 

I need to return columns but the data needed varies on a subcolumn named KEY. Each EVENT can have multiple KEY entries. If KEY is the lowest of EVENT, the formula needs to take the data from column START. If KEY is the highest of EVENT, it needs to take the data from column END. For erverything else, it needs to take the data from MIDDLE.

 

To help figure out what's needed, I summarized things with this Excel table : 

volt26_1-1750704530433.png

 

If we look at EVENT entry 'C'

The desired result should somehow calculate this : 

lowest KEY of EVENT = 35
highest KEY of EVENT = 26
everything else = 14 + 67
Desired result is = 35+26+14+67=142

In other words, I think the right formula would be something like :
START of lowestKEY + ( SUM of MIDDLE for all keys then substracts MIDDLE of lowestKEY and also substract MIDDLE of highestKEY ) + END of highestKEY
=> 
35 + ( (76+14+67+5)-(76+5) ) + 26

I'm not quite familiar with DAX but I learn here and there with tutorials. I couldn't find answers for this specific issue. Thanks for your time!

1 ACCEPTED SOLUTION

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1750739009294.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Here it is : 

 

EVENTKEYSTARTMIDDLEEND
A150618
A2233141
A3451813
B172654
B291790
C1357643
C281421
C3666798
C485526

 

It will most likely be possible to copy-paste it. 🙂

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1750739009294.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you very much! This file does all I need. 
If someone else use this, be aware that the smallest key is entered manually with a static value of 1. In my case, I didn't mention it but the key varies from event to event so I needed to change this static value for "Data[KEY]=MIN(Data[KEY])"

 

Have a wonderful day!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
rajendraongole1
Super User
Super User

Hi @volt26  - Please check the attached pbix file. 

 

rajendraongole1_0-1750705406075.png

 

Hope this helps let me know if any,





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

Proud to be a Super User!





Wow that is very impressive!

 

Unfortunately, I get this error in my real file : 

volt26_0-1750707647202.png

 

It works well when I select one single EVENT but when I select multiple ones, it doesn't.

 

The demo file provided doesn't return the SUM of all the EVENTS either.

 

Do you think it is possible to add this feature? I've never been closer to my goal before you gave me this!

 

I wonder if the formula has to be in the table instead of in a measure?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.