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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

How to find Last Month Value Dynamically

i need last month,   Ticket closed Count

 

i have tried below DAX but it return all the values i need puticular one month value only

 

Tickets Closed (Current Month -1) =
VAR _CurrentDate = MAX('Table'[RequestClosedDate])
VAR _StartMonth = EOMONTH(_CurrentDate,-1)+1
VAR _EndMonth = EOMONTH(_StartMonth,0)+1
VAR _Count =
CALCULATE(
DISTINCTCOUNT(Table'[TicketNo]),
'Table'[RequestClosedDate] >= _StartMonth
&& 'Table'[RequestClosedDate] <= _CurrentDate
)
RETURN

_Count

 

is any way to solve this matter? Thanks in advance!

 

Regards,

Rajesh

7 REPLIES 7
Greg_Deckler
Super User
Super User

@Anonymous - I guess I would think:

Tickets Closed (Current Month -1) =
VAR _CurrentDate = MAX('Table'[RequestClosedDate])
VAR _StartMonthDate = EOMONTH(_CurrentDate,-1)
VAR _StartMonth = DATE(YEAR(_StartMonthDate),MONTH(_StartMonthDate),1)
VAR _EndMonth = EOMONTH(_StartMonth,-1)
VAR _Count =
CALCULATE(
DISTINCTCOUNT(Table'[TicketNo]),
'Table'[RequestClosedDate] >= _StartMonth
&& 'Table'[RequestClosedDate] <= _CurrentDate
)
RETURN

_Count


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler 

 

it's return all the value i need last month ticket closed value only, 

 

 i have ticktno and Request closed date colum ,  i want to distinct count of how many tickets are closed last Month ,  (request closed month column is a date field)

 

any guss?

@Anonymous - Let's back-up. Sample data, expected output.

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler  @amitchandak 

 

i have attached Sample data Click here  

 

i need result like this (3 Month ticket closed Details) - i have already created calender table

 

Unique TicketID Count Monthly basis

 

Ticket Closed Current MonthTicket Closed Last MonthTicket Closed Last Month -1  
12523

 

Thanks & Regards,

Rajesh R

amitchandak
Super User
Super User

@Anonymous , join you close date with date table and use time intelligence

Examples

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
previous month value =  CALCULATE(sum('table'[total hours value]),previousmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

//Without Time Intelligence 
Month Rank = RANKX(all('Date'),'Date'[Month Start date],,ASC,Dense)	
This Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])))
Last Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1))

 

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

 

i have tried EOMONTH(),  and Previousmonth() but it's not working

 

Previous Month() its return wrong value

any guss?

@Anonymous , It should work with Date calendar marked as Date.

Take my file and check. Attached after signature

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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