Forum Discussion
Measure to filter month sales data
Dear PBI Masters,
I got set of data showing sales for number of products ( a,b,c,d ets ) with historical month sales ( 18 months starting form 01/20 to 06/21)
I wanted to show sales only for those products that have zero sales in period 07-12/20. That was easy part:)
it goes like this:
- Anonymous4 years ago
Hi MCG ,
Your measure seems to be wrong:
Please try this instead:
Measure = var _maxDate=CALCULATE(max('Months'[Date]),ALL('Months')) var _dateStart=DATE(YEAR(_maxDate)-1,MONTH(_maxDate)+1,1) var _dateEnd=DATE(YEAR(_maxDate)-1,12,31) var sales=CALCULATE(SUM(Months[Sales]),DATESBETWEEN('Months'[Date],_dateStart,_dateEnd)) return salesIf you want to dynamically show the X-axis base on the selected date period, you may apply a flag measure to filter pane ,like this:
Flag = var _maxDate=CALCULATE(max('Months'[Date]),ALL('Months')) var _dateStart=DATE(YEAR(_maxDate)-1,MONTH(_maxDate)+1,1) var _dateEnd=DATE(YEAR(_maxDate)-1,12,31) return IF(MAX('Months'[Date]) >=_dateStart && MAX('Months'[Date])<=_dateEnd,1,0)Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi MCG ,
Your measure seems to be wrong:
Please try this instead:
Measure = var _maxDate=CALCULATE(max('Months'[Date]),ALL('Months')) var _dateStart=DATE(YEAR(_maxDate)-1,MONTH(_maxDate)+1,1) var _dateEnd=DATE(YEAR(_maxDate)-1,12,31) var sales=CALCULATE(SUM(Months[Sales]),DATESBETWEEN('Months'[Date],_dateStart,_dateEnd)) return salesIf you want to dynamically show the X-axis base on the selected date period, you may apply a flag measure to filter pane ,like this:
Flag = var _maxDate=CALCULATE(max('Months'[Date]),ALL('Months')) var _dateStart=DATE(YEAR(_maxDate)-1,MONTH(_maxDate)+1,1) var _dateEnd=DATE(YEAR(_maxDate)-1,12,31) return IF(MAX('Months'[Date]) >=_dateStart && MAX('Months'[Date])<=_dateEnd,1,0)Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.