Forum Discussion

astridaku's avatar
astridaku
New Member
10 years ago
Solved

Last month

Hello,

 

I am pretty new to dax and your help will be appreciated.

 

I have a table and I need to filter the data from this month.

 

I have no clue how to do it. 

 

thanks in advance!

  • Anonymous's avatar
    Anonymous
    10 years ago

    astridaku You can accomplish this by adding a calculated column to your table. Use the following dax calc and set your outputs to identify the current month.

    IsCurrentMonth = IF(MONTH(test[Date])=Month(NOW()), "Current Month", "Other")

    or rather than text I usually just use bits 1,0 if I'm just filtering on the back end (not in slicers)

    IsCurrentMonth = IF(MONTH(test[Date])=Month(NOW()), 1, 0)

     

    Then in your page/report/visual you can filter to only show current, or use a slicer

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    astridaku You can accomplish this by adding a calculated column to your table. Use the following dax calc and set your outputs to identify the current month.

    IsCurrentMonth = IF(MONTH(test[Date])=Month(NOW()), "Current Month", "Other")

    or rather than text I usually just use bits 1,0 if I'm just filtering on the back end (not in slicers)

    IsCurrentMonth = IF(MONTH(test[Date])=Month(NOW()), 1, 0)

     

    Then in your page/report/visual you can filter to only show current, or use a slicer

    • konstantinos's avatar
      konstantinos
      Memorable Member

      Anonymous astridaku correct me if I am wrong ( I write without testing ) but if you have more than 2 years it will display "current month" for 2 months value. 

      Could it be like 

      IsCurrentMonth =
      IF (
          AND (
              YEAR ( test[Date] ) = YEAR ( NOW () ),
              MONTH ( test[Date] ) = MONTH ( NOW () )
          ),
          "Current Month",
          "Other"
      )

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        konstantinos yep - spot on. Your calc will handle multiple years.

      • HarrisMalik's avatar
        HarrisMalik
        Continued Contributor

        astridaku If the solution is working for you please mark it as Answered in order to help other community members.