Forum Discussion
sam_hoccane
4 years agoHelper I
Calculating based on Previous Rows
Hi All, Data---> FILE I have following querry: I want to create a measure that can calculate future emission (i.e. Forecast =Y) with 15 Percent of increase. To get the acquired furure...
- 4 years ago
Hi sam_hoccane
Here is the sample file with the modification https://www.dropbox.com/t/w8M4gpY3GYZeSNKaComulative 30% Increase = SUMX ( VALUES ( data[Year_Month] ), CALCULATE ( VAR Percentage = 0.3 VAR CurrentDate = MAX ( data[Date] ) VAR CurrentForecast = SELECTEDVALUE ( data[Forecast] ) VAR CurrentEmission = SUM ( data[Emission] ) VAR SummaryTable = CALCULATETABLE ( SUMMARIZE ( Data, data[Year_Month], "@Date", MAX ( data[Date] ), "@Forcast", SELECTEDVALUE ( data[Forecast] ), "@Emission", SUM ( data[Emission] ) ), ALLEXCEPT ( data, data[Travel Source], data[Manager] ) ) VAR NTable = FILTER ( SummaryTable, [@Forcast] = "N" ) VAR YTable = FILTER ( SummaryTable, [@Forcast] = "Y" ) VAR Last2NRecords = TOPN ( 2, NTable, [@Date] ) VAR PenultimateNDate = MINX ( Last2NRecords, [@Date] ) VAR PenultimateNEmission= MINX ( FILTER ( Last2NRecords, [@Date] = PenultimateNDate ), [@Emission] ) VAR YTableBefore = FILTER ( YTable, [@Date] < CurrentDate ) VAR Result = IF ( CurrentForecast = "N", CurrentEmission, PenultimateNEmission * POWER ( 1 + Percentage, COUNTROWS ( YTableBefore ) ) ) RETURN Result ) )
sam_hoccane
4 years agoHelper I
tamerj1
4 years agoCommunity Champion
Ok. Am on my way home. I'll fix it once I reach