Forum Discussion
PREVIOUSMONTH returning blanks
- 3 years ago
Hi jfpalumbo123 ,
I think you'd better create a calendar table.
This is my test table:
If I don't create a calendar table, I will get blank result:
CurrentMonth_sales = CALCULATE(SUM('Table'[Sales]),FILTER('Table','Table'[Month] = SELECTEDVALUE('Table'[Month]))) PreviousMonth_sales_1 = CALCULATE(SUM('Table'[Sales]),PREVIOUSMONTH('Table'[Date]))If I create a calendar table:
CalendarTable = ADDCOLUMNS(CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),"Month",MONTH([Date]))and create relationship between two tables:
You will get correct result:
PreviousMonth_sales_2 = CALCULATE(SUM('Table'[Sales]),PREVIOUSMONTH('CalendarTable'[Date]))Best regards,
Yadong Fang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi jfpalumbo123 ,
I think you'd better create a calendar table.
This is my test table:
If I don't create a calendar table, I will get blank result:
CurrentMonth_sales = CALCULATE(SUM('Table'[Sales]),FILTER('Table','Table'[Month] = SELECTEDVALUE('Table'[Month])))
PreviousMonth_sales_1 = CALCULATE(SUM('Table'[Sales]),PREVIOUSMONTH('Table'[Date]))
If I create a calendar table:
CalendarTable = ADDCOLUMNS(CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),"Month",MONTH([Date]))
and create relationship between two tables:
You will get correct result:
PreviousMonth_sales_2 = CALCULATE(SUM('Table'[Sales]),PREVIOUSMONTH('CalendarTable'[Date]))
Best regards,
Yadong Fang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.