Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Using a variable to filter data so that is show data for current month

I have DAX code that currently creates a slicer that allows you to show deals that are expected to close in the next 30 days, 60 days, 90 days, and lifetime. All of these slicers are currently workin...
  • v-xiaosun-msft's avatar
    3 years ago

    Hi Anonymous ,

     

    According to your description, I created a sample and here is my solution.

    Please first check if the custom column you created is correct.

    1, Make the following modifications according to your method 1.

     

    VAR CurrentMonth =
        ADDCOLUMNS (
            CALCULATETABLE (
                'Tabelle1',
                DATESBETWEEN (
                    'Tabelle1'[Date].[Date],
                    STARTOFMONTH ( 'Tabelle1'[Date] ),
                    EOMONTH ( TODAY (), 0 )
                )
            ),
            "Days Range", "Current Month"
        )
    RETURN
        UNION ( Next30days, Next60days, Next90days, CurrentMonth )
    

     

    Put “Days Range” into slicer, and you can get the final output:

    2, Make the following modifications according to your method 2.

     

    VAR CurrentMonth =
        ADDCOLUMNS (
            CALCULATETABLE ( 'Tabelle1', 'Tabelle1'[CM] = "Current" ),
            "Days Range2", "Curret Month"
        )
    RETURN
        UNION ( Next30days, Next60days, Next90days, CurrentMonth )
    

     

    Put “Days Range2” into slicer, and you can get the final output:

     

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ xiaosun

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