Forum Discussion
prasy14
8 years agoHelper I
Current Year Previous Month DAX
Hello All,
I am not getting correct t calculated value for previous Month column , For example in below screen shot CM sales for March =3,881,693. in PM Sales column of April month i am expecting 3,881,693.
CM Sales = CALCULATE(SUM('sales'[salesamt]), bcalendar[byear]= YEAR(TODAY()))-- Current Year Sales by month
PM Sales = CALCULATE (SUM('sales'[salesamt]),PREVIOUSMONTH(bcalendar[bdate]), bcalendar[biyear]= YEAR(TODAY())) ---Current Year Previous Month Sales
Hi prasy14,
Please try this:
PM Sales = CALCULATE ( SUM ( 'Sales'[SalesAmount] ), FILTER ( ALLSELECTED ( 'bcalendar' ), 'bcalendar'[bdate].[MonthNo] = MONTH ( MAX ( 'bcalendar'[bdate] ) ) - 1 && 'bcalendar'[byear] = YEAR ( TODAY () ) ) )Regards,
Yuliana Gu
7 Replies
- BILASolutionSolution Specialist
- prasy14Helper I
Hi BILASolution,
Thanks for PBIX file, I still get blank values when i use the DAX and I do have same relationship between the tables as yours
- BILASolutionSolution Specialist
- mattbriceSolution Sage
You can try:
PM Sales = CALCULATE ( [CM Sales],PREVIOUSMONTH(bcalendar[bdate]) ) ---Current Year Previous Month Sales
Though if it were me, i'd have a 'Year' slicer, to make it easier.
- v-yulgu-msftMicrosoft Employee
Hi prasy14,
Please try this:
PM Sales = CALCULATE ( SUM ( 'Sales'[SalesAmount] ), FILTER ( ALLSELECTED ( 'bcalendar' ), 'bcalendar'[bdate].[MonthNo] = MONTH ( MAX ( 'bcalendar'[bdate] ) ) - 1 && 'bcalendar'[byear] = YEAR ( TODAY () ) ) )Regards,
Yuliana Gu