Forum Discussion
Acarrier
6 years agoFrequent Visitor
Date table and DATESINPERIOD
Hi All, I am new to power bi. I have a dataset for the production of one of our plants. Since the plant is temporarily down, we have no production records for a number of recent days. Each batch ...
- Anonymous6 years ago
// Calendar must be connected to ProdDate in the // fact table and must be marked as the Date table // in the model. [PrimeWgt LXM] = var __lastVisibleDate = MAX( Calendar[Date] ) var __numOfMonthsBack = SELECTEDVALUE( LastXMonths[LastXMonths Value] ) var __result = CALCULATE( SUM(V_FCE_STATS_BI[PrimeWgt]), DATESINPERIOD( 'Calendar'[Date], __lastVisibleDate, -__numOfMonthsBack, MONTH ) ) return IF( HASONEVALUE( LastXMonths[LastXMonths Value] ), __result )Best
D
Anonymous
6 years agoNot applicable
// Calendar must be connected to ProdDate in the
// fact table and must be marked as the Date table
// in the model.
[PrimeWgt LXM] =
var __lastVisibleDate = MAX( Calendar[Date] )
var __numOfMonthsBack =
SELECTEDVALUE( LastXMonths[LastXMonths Value] )
var __result =
CALCULATE(
SUM(V_FCE_STATS_BI[PrimeWgt]),
DATESINPERIOD(
'Calendar'[Date],
__lastVisibleDate,
-__numOfMonthsBack,
MONTH
)
)
return
IF(
HASONEVALUE( LastXMonths[LastXMonths Value] ),
__result
)
Best
D