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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to fetch beginning date and ending date to the measure

Hello,

I have table named 'Calendar' 

It has colums named: CalendarDate, CalendarWeekBeginningDate, CalendarWeekEndingDate

 

In order for example: 05/02/22, 05/02/22, 05/08/22 
                                  05/01/22, 04/25/22, 05/01/22

Today is 5/2/2022 and still we are in the week. I want to get 04/25/22, 05/01/22 as _weekBeginingPriorWeek and _weekEndingPriorWeek in a DAX function to use as variables. 
When Today is 5/8/2022 I want to get 05/02/22, 05/08/22 as _weekBeginingPriorWeek and visa versa

I use AAS model to create DAX measures, how can i get those two specific days ?


4 REPLIES 4
tackytechtom
Super User
Super User

Hi @Anonymous ,

 

How about this:

tomfox_0-1651609002447.png

 

weekBeginingPriorWeek = 
TODAY() - 6 - WEEKDAY( TODAY() ,2) 
weekEndingPriorWeek = 
TODAY() - WEEKDAY( TODAY() ,2)

 

Not sure whether you wanna use the formulars as above meaning based on todays date, or if you'd like to use your own date column. If the latter fits your case, then just substitute TODAY() with whatever date column you have in your model 🙂

 

Let me know if this helps!

 

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/

 



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Anonymous
Not applicable

I guess It works

I need to try it on again.

Anonymous
Not applicable

qa1.png

 For example : 1st column how many items sold on that day, 2nd column calendar date, 3rd column 1st category item. 

Actually, I'm gonna use those 2 variables in a dax function to filter in the first column 
such as bring me the how many sold item between those two variables ( beginning date of prior week " monday" to ending date of prior week "sunday" )

What I shared the Dax code brings me the total, not seperated day by day.

Anonymous
Not applicable

Measure = CALCULATE(
DATEADD('Calendar'[CalendarWeekBeginningDate],0,DAY),
FILTER('Calendar',
'Calendar'[CalendarDate] = TODAY()-7
 
)
)

I just come up with this solution, It gaves me what I want but I'm not sure
any comments? 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.