Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Create a measure in DAX that filter calendar

A measure that shows us months until curent month +1 or curent month -1 and if we will get 1 (current month -1) or 2 (current month +1) like in picture below0.png1.png2.png


 

1 ACCEPTED SOLUTION

Ok, I'm assuming you wish to show the periods you mention for the current year (if no, you will need to adapt the measures accordingly)

First the date table, which includes a column for YearMonth (which is used to set the periods for the current year)

date table.png

 .

 

Next create two measures, one  for each period you need (the metric I'm showing in this example is the [sum of sales]

Current Month  - 1 =
VAR _Prev =
    YEAR ( TODAY () ) * 100
        + MONTH ( TODAY () ) - 1
RETURN
    IF ( MAX ( 'Date Table'[YearMonth] ) <= _prev, [Sum Sales] )
Current Month + 1 =
VAR _Prev =
    YEAR ( TODAY () ) * 100
        + MONTH ( TODAY () ) + 1
RETURN
    IF ( MAX ( 'Date Table'[YearMonth] ) <= _prev, [Sum Sales] )

Go into the "New Parameter" option under "Modeling" in the ribbon and select "Fields". Give the Parameter a name and drag both the measures into the"Add and reorder fields" box

field.png

 

SP.gif

This creates a new table as you can see in the Fields list, and will automatically add a slicer to the report:

period table.png

 

Set up yur visual with the year and month fields from the date table and add the [Period Sel] to the Y-axis to get:

filed.pngRes.gif

I've attached the sample PBIX file

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

Whether the advice given by @PaulDBrown  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

PaulDBrown
Community Champion
Community Champion

Are you going to select the period via a slicer?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Yep

Ok, I'm assuming you wish to show the periods you mention for the current year (if no, you will need to adapt the measures accordingly)

First the date table, which includes a column for YearMonth (which is used to set the periods for the current year)

date table.png

 .

 

Next create two measures, one  for each period you need (the metric I'm showing in this example is the [sum of sales]

Current Month  - 1 =
VAR _Prev =
    YEAR ( TODAY () ) * 100
        + MONTH ( TODAY () ) - 1
RETURN
    IF ( MAX ( 'Date Table'[YearMonth] ) <= _prev, [Sum Sales] )
Current Month + 1 =
VAR _Prev =
    YEAR ( TODAY () ) * 100
        + MONTH ( TODAY () ) + 1
RETURN
    IF ( MAX ( 'Date Table'[YearMonth] ) <= _prev, [Sum Sales] )

Go into the "New Parameter" option under "Modeling" in the ribbon and select "Fields". Give the Parameter a name and drag both the measures into the"Add and reorder fields" box

field.png

 

SP.gif

This creates a new table as you can see in the Fields list, and will automatically add a slicer to the report:

period table.png

 

Set up yur visual with the year and month fields from the date table and add the [Period Sel] to the Y-axis to get:

filed.pngRes.gif

I've attached the sample PBIX file

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors