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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Tommyvhod
Helper II
Helper II

Multiply colums according latest date

Hi all

 

I would like to create a measure but i am stuck. I have a product, for the product different materials with quantities and unit prices.

But in the table I use I have historical data as well. So there are different unit prices with different dates.

 

What I would like to do is filter out the latest dates for the duplicates and multiply the qty with unit price.

 

Kind of:

Part 1   mat1   1pcs    5Eur   1.12.2019

Part 1    mat2   0.3kg   8eur    5.12.2019

Part 1   mat3   0.8l      12eur    11.12.2019

Part 1    mat1   1pcs     4.5eur   6.1.2019

Part 1    mat3   0.8l      10eur      5.1.2019

Part 2    mat1  0.4pcs      6 eur   6.9.2019

Part 2   mat2  0.6l    8 eur    12.12.2019

......

 

There is an update on part1 mat1 and mat3 (material) with the latest date and only that is what i would like to see in the product (part1)  costs.

 

Thank You

1 ACCEPTED SOLUTION
Parkavi
Frequent Visitor

 Please use the below logic 

 

(1) Create a calculated column for finding the latest date for each group(Part, mat). If need, you include the qty in the filter clause

Latestdate =
CALCULATE(MAX('Table'[date]),FILTER('Table','Table'[Part]=EARLIER('Table'[Part])&&'Table'[Material]=EARLIER('Table'[Material])))
 
(2) Create column Flag for the latest record
Flag = IF('Table'[date]='Table'[latestdate],1,0)
 
Latest record will be flagged as 1 like below
Capture.PNG
Now, filter out the old record by filtering the flag <>0. Also fetch the cost of latest date by using filter context in CALCULATE function
Please let me know if this solutions works
 
 
 
 

View solution in original post

1 REPLY 1
Parkavi
Frequent Visitor

 Please use the below logic 

 

(1) Create a calculated column for finding the latest date for each group(Part, mat). If need, you include the qty in the filter clause

Latestdate =
CALCULATE(MAX('Table'[date]),FILTER('Table','Table'[Part]=EARLIER('Table'[Part])&&'Table'[Material]=EARLIER('Table'[Material])))
 
(2) Create column Flag for the latest record
Flag = IF('Table'[date]='Table'[latestdate],1,0)
 
Latest record will be flagged as 1 like below
Capture.PNG
Now, filter out the old record by filtering the flag <>0. Also fetch the cost of latest date by using filter context in CALCULATE function
Please let me know if this solutions works
 
 
 
 

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.