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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
karms88
New Member

Creating a calculated column to find max date with filter

Hello all, 

 

I am trying to create a new column on my account table that will find the last date an account purchased a specific type of product. 

For reference, here are how the relationships are set up: 

 

karms88_1-1635785408800.png

 

 

The formula that I am currently trying is:

Last Purchase = CALCULATE(MAX(Invoice[Posting Date (Short Date)], FILTER('Product', LEFT('Product'[BC_Global_Dimension_2__c],4) = "2122")))

However, this is a returning an error code of : 

 

"A single value for column 'Posting Date (Short Date)' in table 'Invoice' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

 

 

I have another working column that I am basing this column off of. That column is looking to find the revenue an account has purchased for the same product group. That column is :

Total Product Group Revenue = CALCULATE(SUM('Invoice Line'[Line Amount]),LEFT('Product'[BC_Global_Dimension_2__c], 4) = "2122"))

 

 

Thank you all for the help!!

 

Kyle

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@karms88 

It is difficult to provide a solution without knowing the related columns. This could because you did not have a distinct date column as the calendar.

Try create a new date table= Distinct(Invoice[Posting Date (Short Date)])And connect it new date table with the product table.

 

Then create your measure:

Last Purchase = CALCULATE(MAX(new date table[Posting Date (Short Date)]), FILTER('Product', LEFT('Product'[BC_Global_Dimension_2__c],4) = "2122"))

 

Best regards
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@karms88 

It is difficult to provide a solution without knowing the related columns. This could because you did not have a distinct date column as the calendar.

Try create a new date table= Distinct(Invoice[Posting Date (Short Date)])And connect it new date table with the product table.

 

Then create your measure:

Last Purchase = CALCULATE(MAX(new date table[Posting Date (Short Date)]), FILTER('Product', LEFT('Product'[BC_Global_Dimension_2__c],4) = "2122"))

 

Best regards
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@karms88 , Try the first one like

Last Purchase = CALCULATE(MAX(Invoice[Posting Date (Short Date)]), FILTER('Product', LEFT('Product'[BC_Global_Dimension_2__c],4) = "2122"))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak, thanks so much for the rapid response. 

 

I have altered the column to what you have posted and this removed the error. However, the column is not accurate. It seems to be pulling the date from an accounts most recent invoice, whether that product group was on that invoice or not. Any idea what is causing that issue? 

 

Thanks, 

 

Kyle 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors