Forum Discussion

NLEIGH's avatar
NLEIGH
Helper I
1 year ago

Current month values with DAX

Hi,

 

I have created a new measure which shows values for the whole year, however I also want to have a measure where I can only see values for current month.  The current measure I have is called "Overall Gain"

 

Please can anyone help with this.  I am still very much a novice and would appreciate any help.

 

Many thanks

7 Replies

  • devinsoni's avatar
    devinsoni
    Regular Visitor

    The easiest way to do this is to put a filter on your visual for Date and click Relative Filtering. Then you can select "In this current month" and that visual/table will always show the data for the current month of current year.

    • NLEIGH's avatar
      NLEIGH
      Helper I

      Many thanks, I will try this and let you know if works !

  • could you pls provide some sample data and expected output?

    • NLEIGH's avatar
      NLEIGH
      Helper I

      Many thanks for taking the time to reply, however I think I may have a solution from a suggestion from another member.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi NLEIGH ,

     

    Maybe you can try formula like below:

    Overall Gain = SUM('Table'[SalesAmount])
    Current Month Gain = 
    CALCULATE(
        [Overall Gain],
        FILTER(
            ALL('Date'),
            'Date'[Year] = YEAR(TODAY()) &&
            'Date'[Month] = MONTH(TODAY())
        )
    )
    Whole Year =
    CALCULATE (
        SUM ( 'Table'[SalesAmount] ),
        YEAR ( 'Date'[Date] ) = YEAR ( TODAY () )
    )
    

     

     


    Best Regards,
    Adamk Kong

     

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

     

     

    • NLEIGH's avatar
      NLEIGH
      Helper I

      Hi Adam,

       

      Many thanks for taking the time to reply and give a detailed answer.  However I think I now have a solution from another member.  I appreciate your time & effort.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi NLEIGH ,

         

        If the issue has been resolved, would it be possible to mark it as resolved and I look forward to your feedback.

         

        Best regards,

        Adamk Kong