Forum Discussion
Subrental Supply Analysis to Purchase
- Aug 16, 2021
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.
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.