Forum Discussion

Nolonwabo's avatar
Nolonwabo
New Member
6 years ago
Solved

The syntax for 'month' is incorrect.

When I add a new measure 

Prev_Month_Orders = CALCULATE([Total_Orders], dateadd(AW_Calender_Lookup[Date], -1, month))
I get an error The syntax for 'month' is incorrect. (DAX(CALCULATE([Total_Orders], dateadd(AW_Calender_Lookup[Date], -1. month)))).
 
Please help.
My regional setting is English(United States)
  • Hi, Nolonwabo 

     

    Based on your description, I created data to reproduce your scenario.

    Test:

     

    Calendar:

     

    Calendar = CALENDARAUTO()

     

     

    There is a one-to-one relationship between two tables.

     

    You may create a measure as follows.

     

    Pre_Month_Sales = 
    CALCULATE(
        SUM(Test[Sales]),
        DATEADD('Calendar'[Date],-1,MONTH)
    )

     

     

    Result:

     

    Best Regards

    Allan

     

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

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion
    Are you certain you should not be using ; instead of , Depends on the language setttings. Seems weird, the DAX error is treating the , as a . so I'm guess ; is the way to go.
  • v-alq-msft's avatar
    v-alq-msft
    Icon for Community Support rankCommunity Support

    Hi, Nolonwabo 

     

    Based on your description, I created data to reproduce your scenario.

    Test:

     

    Calendar:

     

    Calendar = CALENDARAUTO()

     

     

    There is a one-to-one relationship between two tables.

     

    You may create a measure as follows.

     

    Pre_Month_Sales = 
    CALCULATE(
        SUM(Test[Sales]),
        DATEADD('Calendar'[Date],-1,MONTH)
    )

     

     

    Result:

     

    Best Regards

    Allan

     

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