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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors