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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not 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 average of the 'Posting Date' for Movement Type 901 for the Batch number.

 

Cullen_0-1739290666868.png

 

1 ACCEPTED SOLUTION
Anonymous
Not 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
    MidPosting
Measure2 = 
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
    _date
Measure days = DATEDIFF([Measure1], [Measure2], DAY)

Then, drag the measure to the card visual.

vjiewumsft_0-1739341906317.png

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.

View solution in original post

3 REPLIES 3
Anonymous
Not 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
    MidPosting
Measure2 = 
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
    _date
Measure days = DATEDIFF([Measure1], [Measure2], DAY)

Then, drag the measure to the card visual.

vjiewumsft_0-1739341906317.png

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.

parry2k
Super User
Super User

@Anonymous sorry not clear what is the expected output, could you please clarify that? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi,   I would like to have a measure using 

Add_Date = FIRSTDATE(Sheet1[Posting Date]) + INT(DATEDIFF(FIRSTDATE(Sheet1[Posting Date]),LASTDATE(Sheet1[Posting Date]),DAY) / 2) that filters by movement type and Plant embedded within the DAX.   Then I would like to subtract this measure from another measure to get how long this batch stayed before moving out.     For example:   

Measure 1= average date for batch # with movement type 901 at Factory FRPB –  Measure 2 = average date for batch number with movement type 68C at FRAA.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.