Forum Discussion

mkloker's avatar
mkloker
Copper Contributor
Aug 15, 2021
Solved

Subrental Supply Analysis to Purchase

Hi everyone, I am trying to automate and create meaningful analyses of Subrental PO data for my company. We are a Film Production Equipment Rental Company that often has to subrent equipment from oth...
  • SergeiBaklan's avatar
    Aug 16, 2021

    mkloker 

    It could be done with PivotTable using data model.

    - creating PivotTable add your data to data model;

    - in Power Pivot create Date table

    (above is straightforward way, in general above better to do with Power Query)

    - create relationships on data for above two tables

    - add DAX measures

    Qty Out:=VAR endDate =
        MAX ( 'Calendar'[Date] )
    RETURN
        CALCULATE (
            SUM ( Table1[Qty] ),
            ALL ( 'Calendar'[Date] ),
            Table1[Date_Out] <= endDate,
            USERELATIONSHIP ( 'Calendar'[Date], Table1[Date_Out] )
        )

     and

    Qty In:=VAR endDate =
        MAX ( 'Calendar'[Date] )
    RETURN
        CALCULATE (
            SUM ( Table1[Qty] ),
            ALL ( 'Calendar'[Date] ),
            'Calendar'[Date] < endDate,
            USERELATIONSHIP ( 'Calendar'[Date], Table1[Date_In] )
        )

    with them

    Qty Diff:=[Qty Out] - [Qty In]

     gives Qty Out for each date (more exactly for the end of each period)

    Finally

    Max in Period:=MAXX (
        VALUES ( 'Calendar'[Date] ),
        [Qty Diff]
    )

    gives max Qty Out in the period.

    PivotTable could be as

    Please check in attached.