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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
PowerBI_RD
Frequent Visitor

Take value from latest date in PQ

Hi all,

 

I have a question about fetching a target that changes with time. I have two tables: the first one has the StartDate for each target output. Users can input a newer date in this table and choose a different target. The second table I have in PQ is a dates tables with all dates ranging from today to 2 years back. I'm looking for a way to fetch the right target value for each of those dates.

 

I have a copy of the report here: https://drive.google.com/file/d/1LWLOiKrrCD37MqrERvpe2LK8Jkc869nS/view?usp=sharing

 

In this I take a list of dates and I check for each date if it is later than the target date. If not I remove the date, otherwise I keep it in. The next step would be to take the latest StartDate and get the target that was associated with that date. So in the screenshot below that would mean row 2 would remain and row 1 would be removed, because on June 5th the target was updated with a new StartDate.

 

PowerBI_RD_0-1717608896957.png

 

I have tried to solve this by grouping on the Date column, but I don't know how to get the latest Target value based on the max StartDate for each Date.

 

I hope someone is able to help me.

 

Thank you.

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

You could merge the target query into the date query, expand the target value and then fill up to replace the null values. All dates prior to the intial target date will be left as null. 

jgeddes_0-1717614170909.png

 





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

Proud to be a Super User!





View solution in original post

2 REPLIES 2
PowerBI_RD
Frequent Visitor

@jgeddes that's actually an elegant and simple solution. Thank you !

jgeddes
Super User
Super User

You could merge the target query into the date query, expand the target value and then fill up to replace the null values. All dates prior to the intial target date will be left as null. 

jgeddes_0-1717614170909.png

 





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

Proud to be a Super User!





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!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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