Forum Discussion
Power-CJ
3 years agoHelper I
DAX Calculated Column for Last Delivery Date
Hello, I'm sure, that the solution is very simple, but i'm not getting in better mode for a while: Sell-to-Customer Shipment Day Last Shipment Day 52555 13.01.2023 52555 03.0...
Anonymous
3 years agoNot applicable
Hi Power-CJ ,
I have created a simple sample, please refer to my pbix file to see if it helps you.
Create a measure.
last shipment da1y =
VAR _1 =
CALCULATE (
MAX ( 'Table'[Shipment Day] ),
FILTER (
ALL ( 'Table' ),
'Table'[Sell-to-Customer] = SELECTEDVALUE ( 'Table'[Sell-to-Customer] )
&& 'Table'[Index]
= SELECTEDVALUE ( 'Table'[Index] ) - 1
)
)
VAR _2 =
CALCULATE (
COUNT ( 'Table'[Last Shipment Day] ),
FILTER (
ALL ( 'Table' ),
'Table'[Sell-to-Customer] = SELECTEDVALUE ( 'Table'[Sell-to-Customer] )
&& 'Table'[Shipment Day] = SELECTEDVALUE ( 'Table'[Shipment Day] )
)
)
RETURN
IF (
_1 = BLANK (),
BLANK (),
IF ( _2 = 1, _1, MINX ( ALL ( 'Table' ), [Measure] ) )
)
Or a column.
last shipment da1y col =
VAR _1 =
CALCULATE (
MAX ( 'Table'[Shipment Day] ),
FILTER (
ALL ( 'Table' ),
'Table'[Sell-to-Customer] = EARLIER( 'Table'[Sell-to-Customer] )
&& 'Table'[Index]
= EARLIER( 'Table'[Index] ) - 1
)
)
VAR _2 =
CALCULATE (
COUNT ( 'Table'[Last Shipment Day] ),
FILTER (
ALL ( 'Table' ),
'Table'[Sell-to-Customer] = EARLIER( 'Table'[Sell-to-Customer] )
&& 'Table'[Shipment Day] = EARLIER( 'Table'[Shipment Day] )
)
)
RETURN
IF (
_1 = BLANK (),
BLANK (),
IF ( _2 = 1, _1, MINX ( ( 'Table' ), [Measure] ) )
)
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.