The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello everybody!
I need to add a column with the end date for the last week.
The following M-Code formats the end of week based on a date:
Date.EndOfWeek(#date(2011, 5, 14))
How can be this transferred for the last week?
Solved! Go to Solution.
You can use Date.StartOfWeek, or subtract the desired number of days from that expression (e.g., -7).
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi @joshua1990 ,
You could refer to @mahoneypat ' suggestion , use Date.StartOfWeek(Date.From(DateTime.LocalNow())) to get start day of current week, then you could -1 to get the end day of last week by below code
= Date.AddDays(Date.StartOfWeek(Date.From(DateTime.LocalNow())),-1)
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
To do it in query, use Date.EndOfWeek(Date.From(DateTime.LocalNow()))
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks! And how can I reference to last week? This will me show the current week.
Hi @joshua1990 ,
You could refer to @mahoneypat ' suggestion , use Date.StartOfWeek(Date.From(DateTime.LocalNow())) to get start day of current week, then you could -1 to get the end day of last week by below code
= Date.AddDays(Date.StartOfWeek(Date.From(DateTime.LocalNow())),-1)
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You can use Date.StartOfWeek, or subtract the desired number of days from that expression (e.g., -7).
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks!
But I need a dynamic function for the last week.
It should be not fixed for just one week.
I need after every refresh (once a week) the end for the corresponding week.