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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
emmet
Frequent Visitor

Select Value by Reference Date

I have a dataset with four fields:

 

1. Customer ID

2. Old Status

3. New Status

4. Status Change Date

 

Note that the Customer ID field is non-unique. In other words, over the timeframe of the data, the same customer can have multiple status changes.

There are six unique Status values. I want to show a breakdown of status by date (for example, a 100% stacked bar chart showing all statuses as of 1/1/2018). This means that the total count of Statuses being reported should equal the distinct count of Customer IDs.

 

 

I was able to solve this by creating a reference table summarizing Customer IDs and pulling in the correct date using the following logic:

-If the minimum date a Customer ID has in the data is greater than the reference date, I want to report the Old Status associated with that minimum date and Customer ID. Otherwise, I want to report the New Status associated with the maximum date that is less than the reference date.

From there, using a Join Key ([Customer ID] & [Status Change Date]) I was able to pull in the correct status value from the original table. However, the performance of this is very slow, and I am hoping to improve it. Any thoughts on how to improve performance?

 

Any help you might have is appreciated.

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

Sample data please. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler, thank you for your response. I've created sample data that you can use here.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors