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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Velvetine27
Helper I
Helper I

Product Aging Life

Hi guys,


I have two tables which look like this :


Table A :

SKUPostingDateQtyMovementBatch
10113/1/20221000ABC123
10115/1/2022-50ABC123
10120/1/2022-30ABC123
10213/1/20222000ABC123
10214/1/2022-100ABC123

 

Table B :

SKUBatchBatchReleaseDate
101ABC12313/1/2022
101BCD23422/2/2022
102ABC123

13/1/2022

 

I'm looking for a way to calculate aging life of the remaining products. Say user selects a date at 1/8/2022 and Aging > 180 days, it should display how many Qty remaining for each SKU that are released more than 180 days ago. I created a calculated column combining the material and batch (KEYBatch) to link the two tables. I'm assuming the DAX looks something like this :

var 180days = CALCULATE(MAX('DATE'[Date]) - 180)

return = CALCULATE(SUM('Table A'[QtyMovement]), FILTER(DATE, DATE[Date] < 180days))

 

Hope you guys can help me. Thanks very much in advance !

1 ACCEPTED SOLUTION

Hi @Velvetine27 ,

Measure = var aging180 = CALCULATE(MAX('DATE'[Date]) - 180)
return 
CALCULATE(SUM('Table A'[QtyMovement]), FILTER('Table A', 'Table A'[PostingDate]<aging180))

The aging180 returns a  half a year before the selected date. When you select 2022/1/8, it would return 2021/7/12. And the "CALCULATE(SUM('Table A'[QtyMovement]), FILTER('Table A', 'Table A'[PostingDate]<aging180))"returns QtyMovement of Table A and PostingDate is earlier than 2021/7/12 .

 

In the table A, there is no date earlier than 2021/7/12. So it returns blank. You can change the measure.

Measure = var aging180 = CALCULATE(MAX('DATE'[Date]) - 180)
return 
CALCULATE(SUM('Table A'[QtyMovement]), FILTER('Table A', 'Table A'[PostingDate]>aging180))

vpollymsft_0-1670217972335.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

6 REPLIES 6
FreemanZ
Super User
Super User

Are you expecting a measure? If so how would it be presented?

How is the Date table related to Table A and B?

It doesnt have to be a measure, just anyway possible to calculate it. I do have another Date table derives from Table A [PostingDate], which is connected to both Table A and B

it seems Table A, Table B and Date Table form a closed loop. How does it look like? i mean the filtering directions between them.

when you say aging, which date is it compared with, SKU PostingDate or BatchReleaseDate?

The relationship table looks like this :

Date > Table A [Posting Date] & Table A[KeyBATCH] < Table B[KeyBatch]

Perhaps the relationship itself is a problem ?

 

Aging should compare MAX date with BatchReleaseDate, and then compute all transactions in Table A from the first PostingDate where it will be equal to BatchReleaseDate until the MAX date. 

 

So I called the Table B[BatchReleaseDate] to Table A. I wrote this query :

var aging180 = CALCULATE(MAX('DATE'[Date]) - 180
return
CALCULATE SUM(Table A[QtyMovement], FILTER(Table A, Table A[BatchReleaseDate]<aging180))
This query doesn't return all results for the PostingDate until today. It somehow only sums few quantity which Im not quite sure what it is filtering.

Please help ! Thank you

Hi @Velvetine27 ,

Measure = var aging180 = CALCULATE(MAX('DATE'[Date]) - 180)
return 
CALCULATE(SUM('Table A'[QtyMovement]), FILTER('Table A', 'Table A'[PostingDate]<aging180))

The aging180 returns a  half a year before the selected date. When you select 2022/1/8, it would return 2021/7/12. And the "CALCULATE(SUM('Table A'[QtyMovement]), FILTER('Table A', 'Table A'[PostingDate]<aging180))"returns QtyMovement of Table A and PostingDate is earlier than 2021/7/12 .

 

In the table A, there is no date earlier than 2021/7/12. So it returns blank. You can change the measure.

Measure = var aging180 = CALCULATE(MAX('DATE'[Date]) - 180)
return 
CALCULATE(SUM('Table A'[QtyMovement]), FILTER('Table A', 'Table A'[PostingDate]>aging180))

vpollymsft_0-1670217972335.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors