Forum Discussion

Lijun_'s avatar
Lijun_
New Member
2 years ago

Previousmonth syntax not working

Hello Guys, I am new to Power BI and run into this problem where the PREVIOUSMONTH sytax returns blank value.

I have two tables: Sales Fact and Date Table. I've built the relationshion between these two tables by Date.

My formula looks like:

Sales PM =
CALCULATE(
SUM(‘Sales Fact'[Sales Amount]),
PREVIOUSMONTH('DATE'[Date])
)

 

If you have any clues about what I did wrong, Please help me out. Thanks!!

4 Replies

  • lukiz84's avatar
    lukiz84
    Icon for Memorable Member rankMemorable Member

    Did you mark the "Date table" as a Date table? 🙂

    • Lijun_'s avatar
      Lijun_
      New Member

      Hi thank you for replying, I did mark the date table as date table. Forgot to mention, I am need to show sales by month-year

  • lukiz84's avatar
    lukiz84
    Icon for Memorable Member rankMemorable Member

    Can you show a diagram of those 2 tables and their relationship? (Sales Fact and Date) - and maybe a screenshot of the matrix?

  • v-weiyan1-msft's avatar
    v-weiyan1-msft
    Icon for Community Support rankCommunity Support

    Hi  Lijun_ , 

     

    According to your description and the dax formula you provided, here is the test I did with my own sample, and there was no problem.
    Since I don’t know the specific situation of your data, in order to help you better locate and solve these problems, I will attach my .pbix file to you. Please try to open it after you receive the file, and compare it with your data and file, to see if you can find any differences.

     

    My Sample:

    Result is as below.

     

    Best Regards,

    Yulia Yan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.