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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply

Latest finished product and corresponding quantity

Hi,
I want to create a last estimate of a produced item (so the latest finished product). I get it correctly with the below Dax formula:
Last Estimate Order =
VAR Last_estimate = MAXX(FILTER(ALLSELECTED(ProductionCalculations), ProductionCalculations[EndedDate.EndedDate]=MAX(ProductionCalculations[EndedDate.EndedDate])), ProductionCalculations[FinishedDate.Finished Date])
RETURN
CALCULATE(MAX(ProductionCalculations[Productions.Prod Id]), FILTER((ProductionCalculations),ProductionCalculations[FinishedDate.Finished Date]= Last_estimate))
 
I am trying as well to add quantity to the received result. I used the similar formula, but unfortunately it gives me the total sum and it changes when swtiching between orders. Can anybody give a hint how to change that to get the values corresponding to that order?
 
Last Estimate Qty =
VAR Last_estimate = MAXX(FILTER(ALLSELECTED(ProductionCalculations), ProductionCalculations[EndedDate.EndedDate]=MAX(ProductionCalculations[EndedDate.EndedDate])), ProductionCalculations[FinishedDate.Finished Date])
RETURN
CALCULATE(SUM(ProductionCalculations[Real consump Qty (kg)]), FILTER((ProductionCalculations),ProductionCalculations[FinishedDate.Finished Date]= Last_estimate))
 
Thank you in advance,
Adam
1 ACCEPTED SOLUTION

Hi,

I think I've got it. Thank a lot for your help.

 

Last Order Quantity in Month (per Product Type) = 
VAR Last_estimate = MAXX(FILTER(ALLSELECTED(ProductionCalculations), ProductionCalculations[EndedDate.EndedDate]=MAX(ProductionCalculations[EndedDate.EndedDate])), ProductionCalculations[FinishedDate.Finished Date])

RETURN
CALCULATE(SUM(ProductionCalculations[Real consump Qty (kg)]),
FILTER((ProductionCalculations),ProductionCalculations[FinishedDate.Finished Date]Last_estimate
    &&ProductionCalculations[Productions.Prod Id] = CALCULATE(MAX ( ProductionCalculations[Productions.Prod Id] ),
                        FILTER ( ProductionCalculations,ProductionCalculations[FinishedDate.Finished Date] = Last_estimate))))

View solution in original post

6 REPLIES 6

Hi,

I think I've got it. Thank a lot for your help.

 

Last Order Quantity in Month (per Product Type) = 
VAR Last_estimate = MAXX(FILTER(ALLSELECTED(ProductionCalculations), ProductionCalculations[EndedDate.EndedDate]=MAX(ProductionCalculations[EndedDate.EndedDate])), ProductionCalculations[FinishedDate.Finished Date])

RETURN
CALCULATE(SUM(ProductionCalculations[Real consump Qty (kg)]),
FILTER((ProductionCalculations),ProductionCalculations[FinishedDate.Finished Date]Last_estimate
    &&ProductionCalculations[Productions.Prod Id] = CALCULATE(MAX ( ProductionCalculations[Productions.Prod Id] ),
                        FILTER ( ProductionCalculations,ProductionCalculations[FinishedDate.Finished Date] = Last_estimate))))

Hi @rajendraongole1. thank you for your solution. It works across whole production when looking for the last produced item. But I realized that I need to add 2 filters in that dax formula, 1 for produced item (as we have many) and the 2nd for month-Year. would it be able to add isflitered twice in this formula?

Thank you in advance,

Anonymous
Not applicable

Hi @AdamPowerBI2024 ,

 

Thank very much for @rajendraongole1  solution, I'll add the appropriate conditions based on this for your needs:

Last Estimate Qty =
VAR Last_estimate =
    MAXX (
        FILTER (
            ALLSELECTED ( ProductionCalculations ),
            ProductionCalculations[EndedDate.EndedDate]
                = MAX ( ProductionCalculations[EndedDate.EndedDate] )
        ),
        ProductionCalculations[FinishedDate.Finished Date]
    )
RETURN
    CALCULATE (
        SUM ( ProductionCalculations[Real consump Qty (kg)] ),
        FILTER (
            ProductionCalculations,
            ProductionCalculations[FinishedDate.Finished Date] = Last_estimate
                && ProductionCalculations[Productions.Prod Id]
                    = CALCULATE (
                        MAX ( ProductionCalculations[Productions.Prod Id] ),
                        FILTER (
                            ProductionCalculations,
                            ProductionCalculations[FinishedDate.Finished Date] = Last_estimate
                        )
                    )
                && ProductionCalculations[ProducedItem] = "YourProducedItem"
                && -- Add your produced item filter here
                FORMAT (
                    ProductionCalculations[FinishedDate.Finished Date],
                    "MM-YYYY"
                ) = "YourMonthYear" -- Add your month-year filter here
        )
    )

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

HI, thank you, but still shows blank. While filtering different produced item and year month, I want to see the latest order for each month and for different product with quantity used for that order. I used this one one as proposed:

Last Estimate Qty 2 =
VAR Last_estimate =
    MAXX (
        FILTER (
            ALLSELECTED ( ProductionCalculations ),
            ProductionCalculations[EndedDate.EndedDate]
                = MAX ( ProductionCalculations[EndedDate.EndedDate] )
        ),
        ProductionCalculations[FinishedDate.Finished Date]
    )
RETURN
    CALCULATE (
        SUM ( ProductionCalculations[Real consump Qty (kg)] ),
        FILTER (
            ProductionCalculations,
            ProductionCalculations[FinishedDate.Finished Date] = Last_estimate
                && ProductionCalculations[Productions.Prod Id]
                    = CALCULATE (
                        MAX ( ProductionCalculations[Productions.Prod Id] ),
                        FILTER (
                            ProductionCalculations,
                            ProductionCalculations[FinishedDate.Finished Date] = Last_estimate
                        )
                    )
                && ProductionCalculations[Produced item.ProducedItem] = "YourProducedItem"
                && ProductionCalculations[Produced item.ProducedItem]),
                FORMAT (
                    ProductionCalculations[FinishedDate.Finished Date],
                    "MM-YYYY"
                ) = ProductionCalculations[FinishedDate.Finished YearMth]
        )
 
Should I also change the formula for the last estimate Order?
Last Estimate Order =
VAR Last_estimate = MAXX(FILTER(ALLSELECTED(ProductionCalculations), ProductionCalculations[EndedDate.EndedDate] = MAX(ProductionCalculations[EndedDate.EndedDate])), ProductionCalculations[FinishedDate.Finished Date])
RETURN
CALCULATE(MAX(ProductionCalculations[Productions.Prod Id]), FILTER((ProductionCalculations),ProductionCalculations[FinishedDate.Finished Date]= Last_estimate))

Hi,

any possible advice?

Thank you

rajendraongole1
Super User
Super User

Hi @AdamPowerBI2024 -  You can adjust the DAX formula to include the correct filtering for the specific order that matches the Last_estimate. modified one below FYR

Last Estimate Qty =
VAR Last_estimate = MAXX(
FILTER(
ALLSELECTED(ProductionCalculations),
ProductionCalculations[EndedDate.EndedDate] = MAX(ProductionCalculations[EndedDate.EndedDate])
),
ProductionCalculations[FinishedDate.Finished Date]
)
RETURN
CALCULATE(
SUM(ProductionCalculations[Real consump Qty (kg)]),
FILTER(
ProductionCalculations,
ProductionCalculations[FinishedDate.Finished Date] = Last_estimate &&
ProductionCalculations[Productions.Prod Id] =
CALCULATE(MAX(ProductionCalculations[Productions.Prod Id]),
FILTER(ProductionCalculations, ProductionCalculations[FinishedDate.Finished Date] = Last_estimate)
)
)
)

 

Hope this helps





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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