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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
murphm6
Helper II
Helper II

Return blank value or max date allexcept?

Hi all,

 

I have a table that shows customers and product combinations over the years. I'm trying to return the most up-to-date price for each customer-product combination. 

 

The table format is below. I want to calculate the max date of the 'To-Date' in a new column so i can summarize the table and pull the latest price into my summarized table. If the 'To-Date' is blank, i want to pull that over any other date listed, because that is the most up-to-date data. How can i return the max date for cust-prod combos in a new calculated column while prioritizing blank values? Examples of desired results are below

murphm6_0-1692124857729.png

murphm6_1-1692124874572.png

 

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @murphm6 ,

 

Here are the steps you can follow:

1. Create calculated column.

Column =
var _maxfromdate=MAXX(FILTER(ALL('Table'),'Table'[Cust]=EARLIER('Table'[Cust])&&'Table'[Product]=EARLIER('Table'[Product])),[From-Date])
var _maxtodate=MAXX(FILTER(ALL('Table'),'Table'[Cust]=EARLIER('Table'[Cust])&&'Table'[Product]=EARLIER('Table'[Product])&&'Table'[From-Date]=_maxfromdate),[To-Date])
return
_maxtodate

2. Result:

When the maximum date is empty:

vyangliumsft_0-1692237784489.png

 

Maximum date when data is available:

vyangliumsft_1-1692237784490.png

 

Best Regards,

Liu Yang

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

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @murphm6 ,

 

Here are the steps you can follow:

1. Create calculated column.

Column =
var _maxfromdate=MAXX(FILTER(ALL('Table'),'Table'[Cust]=EARLIER('Table'[Cust])&&'Table'[Product]=EARLIER('Table'[Product])),[From-Date])
var _maxtodate=MAXX(FILTER(ALL('Table'),'Table'[Cust]=EARLIER('Table'[Cust])&&'Table'[Product]=EARLIER('Table'[Product])&&'Table'[From-Date]=_maxfromdate),[To-Date])
return
_maxtodate

2. Result:

When the maximum date is empty:

vyangliumsft_0-1692237784489.png

 

Maximum date when data is available:

vyangliumsft_1-1692237784490.png

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@murphm6,  a new column

 

maxx(filter(Table, [cust]=earlier([cust]) && [product] = earlier([product]) && not(isblank([to-Date])) ), [to-Date])

 

 

Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8
https://www.youtube.com/watch?v=cN8AO3_vmlY&t=17820s

Hey @amitchandak , i tried this solution and it's still just taking the max date. For cust-prod combinations where there is a blank to-date, it's not returning a blank value

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.