Forum Discussion
jbolivar
7 years agoFrequent Visitor
Parameter What If
Hello friends. According to the function indicated below, a calculation is being made to a specific year (2019). AcumulaPeriodos Unds = // VAR CuentaMeses = CALCULATE(DISTINCTCOUNT(DATA[Mes])...
- 7 years ago
You can create a variable in the starting of the measure and use this variable everywhere:
VAR SelectedYear = FORMAT(SELECTEDVALUE(Paremeter[Paramter]), "####")
Format function will convert the Integer to a Text.
v-juanli-msft
7 years agoCommunity Support
Hi jbolivar
I test on my side, create a what if parameter to add whole number from -10 to 5 to the specific year 2019.
From your post, it seems the columns DATA[AÑO FISCAL] and [AñoMax] are set to type Text.
If you could accept to transform them to type Number, the function below works
AcumulaPeriodos Unds =
VAR CuentaMeses = CALCULATE(DISTINCTCOUNT(DATA[Mes]),
FILTER(DATA,DATA[AÑO FISCAL]=2019+[Parameter Value]))
VAR DiferenciaMeses= 12-CuentaMeses
RETURN IF(MAX([AñoMax])=2019+[Parameter Value],CALCULATE([mTOTALVENTAS Und.],
FILTER(DATA,DATA[AÑO FISCAL]=2019+[Parameter Value])),
CALCULATE(SUM(DATA[Unidades]),PARALLELPERIOD(DATA[Fecha],-DiferenciaMeses,MONTH)))
If you need keep the columns DATA[AÑO FISCAL] and [AñoMax] type Text, functions below works
Measure = FORMAT(2019+[Parameter Value],"General Number")
AcumulaPeriodos Unds =
VAR CuentaMeses = CALCULATE(DISTINCTCOUNT(DATA[Mes]),
FILTER(DATA,DATA[AÑO FISCAL]=[Measure]))
VAR DiferenciaMeses= 12-CuentaMeses
RETURN IF(MAX([AñoMax])=[Measure],CALCULATE([mTOTALVENTAS Und.],
FILTER(DATA,DATA[AÑO FISCAL]=[Measure])),
CALCULATE(SUM(DATA[Unidades]),PARALLELPERIOD(DATA[Fecha],-DiferenciaMeses,MONTH)))
Best Regards
Maggie