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
rennda
Frequent Visitor

Reference last row values filtered by multiple criteria

Dear Power BI community: I would really appreciate if you could help me out with my following problem. I would like to expand my table with the colums "Last Call" and "Last Employee" by a reference to the last row (matching MachineNo)

 

I try to fix my problem meanwhile for over two weeks and there ist actually no way to find a solution for me. So please help 🙂

 

CALL_IDMachineNoModellCall_DateLast CallEmployeeLast Employee
2908330408427KYOC TA 4551CI12.12.2018 16:27 KM 
2923350408427KYOC TA 4551CI04.01.2019 10:4612.12.2018 16:27KMKM
2925603408427KYOC TA 4551CI09.01.2019 10:2404.01.2019 10:46BTKM
2934951426616SHAR MXM90423.01.2019 16:07 SD 
2956653426616SHAR MXM90427.02.2019 10:4923.01.2019 16:07DSSD
2965052426616SHAR MXM90414.03.2019 14:4127.02.2019 10:49BPDS
2971818408427KYOC TA 4551CI26.03.2019 10:2109.01.2019 10:24BTBT
2972146426616SHAR MXM90426.03.2019 14:5514.03.2019 14:41WHBP
2989954426616SHAR MXM90405.04.2019 11:2926.03.2019 14:55WHWH
3005277426616SHAR MXM90407.05.2019 11:5105.04.2019 11:29SDWH
1 ACCEPTED SOLUTION

Hi @rennda ,

I created a sample to get the last row values. And you can check if it is what you want.

Last call date = CALCULATE(MAX('Table'[Call_Date]),FILTER(ALLEXCEPT('Table','Table'[MachineNo]),'Table'[Call_Date] <= EARLIER('Table'[Call_Date])-1))
Group rank = RANKX(FILTER('Table','Table'[MachineNo]=EARLIER('Table'[MachineNo])),'Table'[Call_Date],,ASC,Dense)
Last Employee = CALCULATE(MAX('Table'[Employee]),FILTER('Table', 'Table'[MachineNo] = EARLIER('Table'[MachineNo]) &&'Table'[Group rank] = EARLIER('Table'[Group rank])-1))
Last call date2 = CALCULATE(MAX('Table'[Call_Date]),FILTER('Table', 'Table'[MachineNo] = EARLIER('Table'[MachineNo]) &&'Table'[Group rank] = EARLIER('Table'[Group rank])-1))

3.PNG

I attached my sample that you can download.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Cmcmahan
Resident Rockstar
Resident Rockstar

I've got bad news and good news for you.  The good news is that this IS doable within DAX.  The bad news is that it is not efficient and if you have a large data set will run incredibly slowly.

You can read about somebody who had a similar problem here.  Be sure to read through all the replies first, because there was a lot of iteration on different methods for performance for that question.  Give it a try, and if you have questions about how to implement the solution for your dataset, feel free to ask follow up questions.

Hey @Cmcmahan ,

 

thanks for your reply. I tried it to read the link you have posted, but it seems to be to much information to me as a Power BI Rookie 🙂

 

Is it possible to get the Name from the EMPLOYEE from the last TicketNo by the EARLIER function?  

Hi @rennda ,

I created a sample to get the last row values. And you can check if it is what you want.

Last call date = CALCULATE(MAX('Table'[Call_Date]),FILTER(ALLEXCEPT('Table','Table'[MachineNo]),'Table'[Call_Date] <= EARLIER('Table'[Call_Date])-1))
Group rank = RANKX(FILTER('Table','Table'[MachineNo]=EARLIER('Table'[MachineNo])),'Table'[Call_Date],,ASC,Dense)
Last Employee = CALCULATE(MAX('Table'[Employee]),FILTER('Table', 'Table'[MachineNo] = EARLIER('Table'[MachineNo]) &&'Table'[Group rank] = EARLIER('Table'[Group rank])-1))
Last call date2 = CALCULATE(MAX('Table'[Call_Date]),FILTER('Table', 'Table'[MachineNo] = EARLIER('Table'[MachineNo]) &&'Table'[Group rank] = EARLIER('Table'[Group rank])-1))

3.PNG

I attached my sample that you can download.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

WOW! Thanks to @v-xuding-msft  for this fast solution. So i could diving into the weekend now. Phenomanally! Robot Very Happy


@v-xuding-msft wrote:

Hi @rennda ,

I created a sample to get the last row values. And you can check if it is what you want.

Last call date = CALCULATE(MAX('Table'[Call_Date]),FILTER(ALLEXCEPT('Table','Table'[MachineNo]),'Table'[Call_Date] <= EARLIER('Table'[Call_Date])-1))
Group rank = RANKX(FILTER('Table','Table'[MachineNo]=EARLIER('Table'[MachineNo])),'Table'[Call_Date],,ASC,Dense)
Last Employee = CALCULATE(MAX('Table'[Employee]),FILTER('Table', 'Table'[MachineNo] = EARLIER('Table'[MachineNo]) &&'Table'[Group rank] = EARLIER('Table'[Group rank])-1))
Last call date2 = CALCULATE(MAX('Table'[Call_Date]),FILTER('Table', 'Table'[MachineNo] = EARLIER('Table'[MachineNo]) &&'Table'[Group rank] = EARLIER('Table'[Group rank])-1))

3.PNG

I attached my sample that you can download.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



@v-xuding-msft wrote:

Hi @rennda ,

I created a sample to get the last row values. And you can check if it is what you want.

Last call date = CALCULATE(MAX('Table'[Call_Date]),FILTER(ALLEXCEPT('Table','Table'[MachineNo]),'Table'[Call_Date] <= EARLIER('Table'[Call_Date])-1))
Group rank = RANKX(FILTER('Table','Table'[MachineNo]=EARLIER('Table'[MachineNo])),'Table'[Call_Date],,ASC,Dense)
Last Employee = CALCULATE(MAX('Table'[Employee]),FILTER('Table', 'Table'[MachineNo] = EARLIER('Table'[MachineNo]) &&'Table'[Group rank] = EARLIER('Table'[Group rank])-1))
Last call date2 = CALCULATE(MAX('Table'[Call_Date]),FILTER('Table', 'Table'[MachineNo] = EARLIER('Table'[MachineNo]) &&'Table'[Group rank] = EARLIER('Table'[Group rank])-1))

3.PNG

I attached my sample that you can download.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


 

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.