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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
azeenk
Helper I
Helper I

I Need help on creating DAX or any other approach for getting last 3 months separately dynamically

Dear Team,

 

I am currently developing three dynamic donut charts in Power BI to display data for the last three completed months. These charts will automatically update each month. For example:

  • April: Charts will display data for January, February, and March.

  • May: Charts will update to show February, March, and April.

Each chart will be filtered to its respective month, formatted as MMM_yyyy (e.g., Jan_2025), ensuring consistency and clarity.

Please let me know if you have any preferences or additional requirements for these visuals.

 

 

Best regards,
Hk

1 ACCEPTED SOLUTION

Hi @azeenk 

 

Would a measure like this help?

Last 3 months = 
VAR _End = EOMONTH( MAX( 'Date'[Date] ), -1 )
VAR _Start = EOMONTH( _End, -3 ) + 1
VAR _Sales =
    CALCULATE(
        [Sales],
        'Date'[Date] >= _Start
            && 'Date'[Date] <= _End
    )
RETURN
    _Sales

 

Last 3 completed months.pbix

 

Page 1 is a summary by month.

Page 2 uses a slicer on month.

 

Let me know if you have any questions.



Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

7 REPLIES 7
v-kathullac
Community Support
Community Support

Hi @azeenk  ,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.


Regards,

Chaithanya.

v-kathullac
Community Support
Community Support

Hi @azeenk  ,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.


Regards,

Chaithanya.

v-kathullac
Community Support
Community Support

Hi @azeenk ,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.


Regards,

Chaithanya.

Hi @v-kathullac,

The solution did not work as expected and still working on it.

Hi @azeenk 

 

Would a measure like this help?

Last 3 months = 
VAR _End = EOMONTH( MAX( 'Date'[Date] ), -1 )
VAR _Start = EOMONTH( _End, -3 ) + 1
VAR _Sales =
    CALCULATE(
        [Sales],
        'Date'[Date] >= _Start
            && 'Date'[Date] <= _End
    )
RETURN
    _Sales

 

Last 3 completed months.pbix

 

Page 1 is a summary by month.

Page 2 uses a slicer on month.

 

Let me know if you have any questions.



Proud to be a Super User!

daxformatter.com makes life EASIER!
sjoerdvn
Super User
Super User

The way I usually do this is to create a relative month column on my date dimension, with 0 being the current month, 1 the next month, -1 the previous month etc. This way you can use simply apply a page or visual filter on that column and just select the values -1,-2 and -3 to get the previous three months.
You could implement this by adding a computed column to your date/calendar dimension table, e.g.:

Relative Month = DATEDIFF(TODAY(),[Date],MONTH)
BeaBF
Super User
Super User

@azeenk Hi! Do you have month name or date? can you paste some sample data on which you need to create these visuals?

 

Thx, BBF


💡 Did I answer your question? Mark my post as a solution!

👍 Kudos are appreciated

🔥 Proud to be a Super User!

Community News image 1920X1080.png

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.