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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Hogan
New Member

How do I return the first value by order related to an ID as a window function?

What I am working with:


    I have the limitation that my data is sourced from a sharepoint folder and it appends tables from about 24 excel documents for a grand total of 17,000,000 records and about 40 columns. Half these columns are ID columns so they have a large number of distinct values, and they use text in the key values. I know this isn't how things should be done, but this is what I have to work with and I have to figure it out.

 

    This is why the solution has to be in DAX (preferably calculated columns) because there is no database to fold the query back on, and when I tried this in power query I had to cut off the report at about 45 minuts of refresh time. I need the attributes to all stay in the same relationship to each other that they started in, so MINX() and MAXX() will not work. LOOKUPVALUE() also does not work because it is not feasible to duplicate the ID column, that hurts performance too much and refresh time is already at 30 minutes.  

What I have:     

ID_COLUMNNAME_COLUMNREGION_COLUMN
1Jonwest
2Bobwest
2Maryeast
2Aaronsouth
3Tammynorth
3Billeast
4Judithsouth
5Allywest
5Joshnorth

 

What I would like DAX to do:   (See the last two columns)           

ID_COLUMNNAME_COLUMNREGION_COLUMNMy_New DAX_MeasureMy_New_DAX_Measure_column_2
1JonwestJonwest
2BobwestBobwest
2MaryeastBobwest
2AaronsouthBobwest
3TammynorthTammynorth
3BilleastTammynorth
4JudithsouthJudith south
5AllywestAllywest
5JoshnorthAllywest



I am open to any suggestion that can get this solution.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Well, you will need to define "first" and "last". You could add an Index column in Power Query to do this, then you could use Lookup Min/Max - https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

 

You also might find this amusing - https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Mythical-DAX-Index/m-p/1093214#M528


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Well, you will need to define "first" and "last". You could add an Index column in Power Query to do this, then you could use Lookup Min/Max - https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

 

You also might find this amusing - https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Mythical-DAX-Index/m-p/1093214#M528


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you Greg, this not only works for this but I can see a broad number of uses for it. It is a really cool DAX trick, using this in a table variable to create a dynamic index based on the initial filter context has me geeking out a little.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors