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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Responsive Resident
Responsive Resident

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 )
    )

 

"The commonality between science and art is in trying to see profoundly - to develop strategies of seeing and showing." - Edward Tufte

View solution in original post

2 REPLIES 2
dearwatson
Responsive Resident
Responsive Resident

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 )
    )

 

"The commonality between science and art is in trying to see profoundly - to develop strategies of seeing and showing." - Edward Tufte

Thanks for the help!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.