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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
julien-rivley
Helper I
Helper I

Calculate future expiry of product

Hello,

 

I'm trying to calculate the future stock expiry for each of the future months with the following data:

- current month opening stock by expiry date
- demand of the current and all the future months

I believe to have found a way to calculate it to calculate it but I'm stuck at combining 2 table, here are the details
Current month opening stock table by expiry date:

YearMonthCurrent month stock by expiry date
Jan-201000
Mar-20450
May-201000
Oct-20100


Demand table:

YearMonthDemandCumulated Demand
Jul-19100100
Aug-19100200
Sep-19100300
Oct-19100400
Nov-19100500
Dec-19100600
Jan-20100700
Feb-20100800
Mar-20100900
Apr-201001000
May-201001100
Jun-201001200
Jul-201001300
Aug-201001400
Sep-201001500
Oct-201001600
Nov-201001700
Dec-201001800
Jan-211001900
Feb-211002000
Mar-211002100


What I would like:

YearMonthCurrent month stock by expiry dateCumulated demand
Jan-201000700
Mar-20450900
May-2010001100
Oct-201001600



My issue is that "YearMonth" in the 2 tables are not related in the data model... is there any way to join these 2 tables? I tried NATURALLEFTOUTERJOIN but it doesn't seem to work.

Thanks,

Julien

1 ACCEPTED SOLUTION
dearwatson
Continued Contributor
Continued Contributor

Hi Julien, 

 

You can build a measure that first gets the "CurrentYearMonth" then filters the second table to return only that row and sum the cumulated demand:

 

Cumulated Demand = 
VAR CurrentYearMonth =
    MAX ( Table1[YearMonth] )
RETURN
    CALCULATE (
        SUM ( Table2[Cumulated Demand] ),
        FILTER ( Table2, Table2[YearMonth] = CurrentYearMonth )
    )

 

View solution in original post

2 REPLIES 2
dearwatson
Continued Contributor
Continued Contributor

Hi Julien, 

 

You can build a measure that first gets the "CurrentYearMonth" then filters the second table to return only that row and sum the cumulated demand:

 

Cumulated Demand = 
VAR CurrentYearMonth =
    MAX ( Table1[YearMonth] )
RETURN
    CALCULATE (
        SUM ( Table2[Cumulated Demand] ),
        FILTER ( Table2, Table2[YearMonth] = CurrentYearMonth )
    )

 

Thanks for the help!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.