Forum Discussion
maart666
5 years agoHelper I
Subtract values from two rows in matrix
Hello, Every week I get sales forecasts for which I have to compare the values. Sample model here: PBI file ...
- 5 years ago
Hi maart666 ,
Modify your measure as below:
Difference = VAR thisforecastnum = MIN ( Arkusz1[Forecast no] ) VAR thisforecast = SUM ( Arkusz1[Qty] ) var lastforecastnum=CALCULATE(MAX('Arkusz1'[Forecast no]),FILTER(ALLSELECTED(Arkusz1),'Arkusz1'[Forecast no]<MAX('Arkusz1'[Forecast no]))) VAR lastforecast = CALCULATE ( SUM ( Arkusz1[Qty] ), Arkusz1[Forecast no] = lastforecastnum ) RETURN IF ( ISBLANK ( lastforecast ), BLANK (), thisforecast - lastforecast )And you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
maart666
5 years agoHelper I
Thank you Pat!
It works perfectly when I compare data from subsequent forecasts. But if the forecasts are not consecutive e.g. 1 and 3 (I know I should mentioned this) the values are incorrect:
Could you help solve this problem?
Thank you.
Marcin
v-kelly-msft
5 years agoCommunity Support
Hi maart666 ,
Modify your measure as below:
Difference =
VAR thisforecastnum =
MIN ( Arkusz1[Forecast no] )
VAR thisforecast =
SUM ( Arkusz1[Qty] )
var lastforecastnum=CALCULATE(MAX('Arkusz1'[Forecast no]),FILTER(ALLSELECTED(Arkusz1),'Arkusz1'[Forecast no]<MAX('Arkusz1'[Forecast no])))
VAR lastforecast =
CALCULATE (
SUM ( Arkusz1[Qty] ),
Arkusz1[Forecast no] = lastforecastnum
)
RETURN
IF (
ISBLANK ( lastforecast ),
BLANK (),
thisforecast - lastforecast
)
And you will see:
For the related .pbix file,pls see attached.
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!