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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Syndicate_Admin
Administrator
Administrator

Minimum Product Date with Batch

Dear

Along with greeting you, I would like to request your collaboration in a dilemma that blows my mind and I have not managed to solve.

I am trying to find the closest date to expire per product, but each of them has N lots, and this has complicated the calculation.

I show them in 2 visual tables to explain them better. "vctomin" is the measure I am using to look for the minimum date. In the first table when using the fields products with their respective lot brings me each of the expiration dates per lot, but when removing the lot field I need to show the closest date of the product to expire, but by doing this it shows me what is indicated in the second table.

This is the formula I am using, which I have modified in many different ways without getting the result I need.

CALCULATE(MIN(Stock[FechaVcto]),
FILTER(
ALL(calendar),
calendar[Date] <= Max(calendar[Date])),filter(all(Measurement), Measurement[Stock] > 0))

Captura de pantalla 2022-06-09 115706.jpg

My idea is that in the field indicated by the arrow show the closest date to expire, in the case of the example it would be 16-08-2022.

Thank you very much in advance.

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Gsv 

 

You can try this measure

Closest date to expire =
CALCULATE (
    MIN ( Stock[FechaVcto] ),
    ALLSELECTED ( 'Stock'[Lote] ),
    Measurement[Stock] > 0
)

Or

Closest date to expire =
CALCULATE (
    MIN ( Stock[FechaVcto] ),
    ALLEXCEPT ( 'Stock', 'Stock'[Producto], 'Stock'[GLOSA] ),
    Measurement[Stock] > 0
)

 

If they don't work, can you please provide some mock data to show the tables as well as relationships among tables? 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

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.