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
Anonymous
Not applicable

Current WeekDates

Hi 

i would like to know how to write a DAX code that shows 

the current week dates 

 

eg. Monday - 01 March 2021 till Sunday 07 March 2021

 

Thank you 

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, I guess that you want to transform your data value in the format as “Monday - 01 March 2021” and place it into a Slicer. I think you can achieve this using a calculated column because measure can not be placed into Slicer in Power BI. you can try this calculate column:

current week date =

var _weekday=FORMAT([Date],"dddd")

var _daynumber=DAY([Date])

var _month=FORMAT([Date],"mmmm")

var _year=YEAR([Date])

return

_weekday&"-"&_daynumber&" "&_month&" "&_year

The output of this calculated column is like this:

v-robertq-msft_0-1615185444814.png

 

Then you can create a Slicer and place it into the slicer, like this:

v-robertq-msft_1-1615185444838.png

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

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

View solution in original post

5 REPLIES 5
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, I guess that you want to transform your data value in the format as “Monday - 01 March 2021” and place it into a Slicer. I think you can achieve this using a calculated column because measure can not be placed into Slicer in Power BI. you can try this calculate column:

current week date =

var _weekday=FORMAT([Date],"dddd")

var _daynumber=DAY([Date])

var _month=FORMAT([Date],"mmmm")

var _year=YEAR([Date])

return

_weekday&"-"&_daynumber&" "&_month&" "&_year

The output of this calculated column is like this:

v-robertq-msft_0-1615185444814.png

 

Then you can create a Slicer and place it into the slicer, like this:

v-robertq-msft_1-1615185444838.png

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

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

amitchandak
Super User
Super User

@Anonymous , You can try like

 

Week Start date = today() +-1*WEEKDAY('today() ,2)+1
Week End date = today() + 7-1*WEEKDAY(today() ,2)

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
Anonymous
Not applicable

Thank you for this 

however i need to place this as a measure so that it shows on the slicer

@Anonymous , for that you need to have this type of column in your date table and use that as filter

 

Week Type = Switch( True(),
[start week]<=Today() && [end date]>=Today(),"This Week" ,
[start week]<=Today()-7 && [end date]>=Today()-7,"Last Week" ,
[Week Name]
)

 

Refer this video : https://www.youtube.com/watch?v=hfn05preQYA

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
Anonymous
Not applicable

hi 

unfortunately this is not working for me 

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.