Forum Discussion
Anonymous
1 year agoNot applicable
Summarize Average Date by Batch Number and Movement Type
I would like to summarize the batch numbers by movement type. For example, Batch 3T36 has multiple entries. They all have the same movement type but different dates. I would like to take the aver...
- Anonymous1 year ago
Hi Anonymous ,
Based on the information, try using the following DAX formula to calculate the date.
Measure1 = VAR FirstPosting = CALCULATE( FIRSTDATE(TEST[Posting Date]), TEST[Movement Type] = "901", TEST[Plant] = "FRPB" ) VAR LastPosting = CALCULATE( LASTDATE(TEST[Posting Date]), TEST[Movement Type] = "901", TEST[Plant] = "FRPB" ) VAR MidPosting = FirstPosting + INT(DATEDIFF( FirstPosting, LastPosting, DAY ) / 2) RETURN MidPostingMeasure2 = VAR FirstPosting = CALCULATE( FIRSTDATE(TEST[Posting Date]), TEST[Movement Type] = "68C", TEST[Plant] = "FRAA" ) VAR LastPosting = CALCULATE( LASTDATE(TEST[Posting Date]), TEST[Movement Type] = "68C", TEST[Plant] = "FRAA" ) VAR _date = FirstPosting + INT(DATEDIFF( FirstPosting, LastPosting, DAY ) / 2) RETURN _dateMeasure days = DATEDIFF([Measure1], [Measure2], DAY)Then, drag the measure to the card visual.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
1 year agoNot applicable
Hi Anonymous ,
Based on the information, try using the following DAX formula to calculate the date.
Measure1 =
VAR FirstPosting =
CALCULATE(
FIRSTDATE(TEST[Posting Date]),
TEST[Movement Type] = "901",
TEST[Plant] = "FRPB"
)
VAR LastPosting =
CALCULATE(
LASTDATE(TEST[Posting Date]),
TEST[Movement Type] = "901",
TEST[Plant] = "FRPB"
)
VAR MidPosting =
FirstPosting
+ INT(DATEDIFF( FirstPosting, LastPosting, DAY ) / 2)
RETURN
MidPostingMeasure2 =
VAR FirstPosting =
CALCULATE(
FIRSTDATE(TEST[Posting Date]),
TEST[Movement Type] = "68C",
TEST[Plant] = "FRAA"
)
VAR LastPosting =
CALCULATE(
LASTDATE(TEST[Posting Date]),
TEST[Movement Type] = "68C",
TEST[Plant] = "FRAA"
)
VAR _date =
FirstPosting
+ INT(DATEDIFF( FirstPosting, LastPosting, DAY ) / 2)
RETURN
_dateMeasure days = DATEDIFF([Measure1], [Measure2], DAY)
Then, drag the measure to the card visual.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.