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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
tutuk28
Helper IV
Helper IV

Add last month closed flag in DAX or Power Query

Hi everyone !

 

I need to show the data up to the last closed month in my report.
Example: today is 10/15 (October is an open month) in this case I need to view all the data for the year up to 09/30 (last closed month).

Could you create this flag in DAX or Power Query?

 

Thank you!

Regards!

1 ACCEPTED SOLUTION

You can add this column to your Date table and then filter on "Y" to see only closed months.

 

Closed Month = if(EOMONTH('Date'[Date],0) <= TODAY(), "Y", "N")
 
Regards,
Pat
 




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@tutuk28 , You can use YTD with date table and force it stop at last month

 

LYMTD QTY forced=
var _dt = eomonth(today(),-1) // Or // maxx(allselected(Date),Date[Date])
return

if('Date'[Date]<=_max,CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year))), blank())

 

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 :radacad sqlbi My Video Series Appreciate your Kudos.

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak , thanks for yo answer.

 

My idea is to add a flag in a page filter, but not for a measure. I wanted to know if it is possible to define this in my calendar dimension either in DAX or Power Query.

 

Regards!

 

You can add this column to your Date table and then filter on "Y" to see only closed months.

 

Closed Month = if(EOMONTH('Date'[Date],0) <= TODAY(), "Y", "N")
 
Regards,
Pat
 




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks @mahoneypat  !

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.