Forum Discussion
sam_hoccane
4 years agoHelper I
Multiplication with Previous Values
Excel File: Link Hello, Could you please help me write the following DAX Querry? I want to create a measure to calculate values highlighted blue in the predicted-CO2 emission column using the...
- 4 years ago
sam_hoccane
Your wishes are my command 😉 Here is the workable solution exactly as you wish
https://we.tl/t-bo914kjbfJPredicted_Measure_4 = VAR CurrentEmission = SUM ( Data[Emission] ) VAR CurrentMonth = SELECTEDVALUE ( data[Year_Month] ) VAR CurrentForcast = SELECTEDVALUE ( Data[forcast] ) VAR PreviousMonths = FILTER ( ALLSELECTED ( Data ), data[Year_Month] < CurrentMonth ) VAR PreviousN_Months = FILTER ( PreviousMonths, Data[forcast] = "N" ) VAR PreviousN_Month = MAXX ( PreviousN_Months, data[Year_Month] ) VAR PreviousN_Emission = SUMX ( FILTER ( PreviousN_Months, data[Year_Month] = PreviousN_Month ), Data[Emission] ) VAR YearMonthOnly = DISTINCT ( SELECTCOLUMNS ( PreviousMonths, "@YearMonth", Data[Year_Month] ) ) VAR NumberOfY_Months = COUNTROWS ( FILTER ( YearMonthOnly, [@YearMonth] > PreviousN_Month && [@YearMonth] <= CurrentMonth ) ) + 1 VAR Result = IF ( CurrentForcast = "N", CurrentEmission, PreviousN_Emission * POWER ( 1.15, NumberOfY_Months ) ) RETURN Result
sam_hoccane
4 years agoHelper I
tamerj1 thankyou so much for your help 🙂 your are my angel 🙂
I have one last request. I was trying to find cummulative emission but it was not producing the results. Would you please suggest way arround.
Predicted _Cumulative_Emission =
CALCULATE( [Predicted_measure_4] , FILTER ( ALLSELECTED(data) ,data[Date] < max (data[Date])))
Here is link to data
tamerj1
4 years agoCommunity Champion
sam_hoccane
Here you go https://we.tl/t-tfEd37slkZ
Comulative Predected =
VAR CurrentMonth = MAX ( data[Year_Month] )
VAR T1 = FILTER ( ALLSELECTED ( data[Year_Month] ), data[Year_Month] <= CurrentMonth )
RETURN
CALCULATE ( SUMX ( T1, [Predicted_Measure_4] ), ALLEXCEPT ( data, data[Type], data[Manager] ) )