Forum Discussion
Highest previous value
- 4 years ago
Hi Anonymous
Please try the following Measure.
higest previous order mth =
VAR midT =
TOPN (
1,
FILTER (
SUMMARIZE (
ALL ( DimTable ),
DimTable[Month],
DimTable[MonthYearNumber],
"val", SUMX ( DimTable, [#Orders] )
),
DimTable[MonthYearNumber] <= MIN ( DimTable[MonthYearNumber] )
),
[val], DESC
)
return MAXX ( midT, [val] )
Then, the result should look like this.
For more details, please refer to the attached pbix file.
Best Regards,
Community Support Team _ Caiyun
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Anonymous you can either create a calculated column like this
Column =
var _monthIndex = Calculate(MAX('Table'[MonthIndex]))
return MAXX(FILTER(ALL('Table'),'Table'[MonthIndex]<=_monthIndex),'Table'[Sales])
or a measure like this
Measure =
var _monthIndex = MAX('Table'[MonthIndex])
return MAXX(FILTER(ALL('Table'),'Table'[MonthIndex]<=_monthIndex),'Table'[Sales])
thanks for your response. it didnt work for me. when i drag in each store
- smpa014 years agoCommunity Champion
Anonymous provide sample pbix or put the screenshot of the error here.
- Anonymous4 years agoNot applicable
Whenever i have 0 as a value for a month for each customer then i dont get the highest previous month using my own solution. However if the currenth month sales is greater than zero then it works . See below
- smpa014 years agoCommunity Champion
Anonymous any chance you can post the sample pbix?
- Anonymous4 years agoNot applicableCALCULATE([#Orders],TOPN(1,FILTER(SUMMARIZE(ALL(dimDate),dimDate[Month], dimDate[MonthYearNumber]),dimDate[MonthYearNumber] <= MIN(dimDate[MonthYearNumber])), [#Orders], DESC))The above is the dax code i am currently using but doesnt work if the measure #orders returns zero for the current month like in the previously shared screenshot