Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I have a JSON query which loads data into my report. Instead of hard coding a date I want a dynamic value. I have managed to get to the point where my json URL contains: &startDate=2020-01-01&endDate=" & Parameter1 & "& where Parameter1 is a text parameter I've typed out '2020-12-01' but I would like to replace this with something like:
Date.EndOfMonth(date.utcnow,0) so if the date today is 5th June 2020, it returns 30th June 2020 in the format 2020-06-30, once we get to say 2nd July 2020, it returns 31st July 2020 in the format 2020-07-31.
Thanks.
This M expression will get you the end of the current month in the format you need for the web call.
let
Source = Date.EndOfMonth(Date.From(DateTime.LocalNow())),
#"Converted to Table" = #table(1, {{Source}}),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Today", each Text.AfterDelimiter([Column1],"/",1) & "-" & Text.PadStart(Text.BeforeDelimiter([Column1],"/", 0), 2,"0") & "-" & Text.PadStart(Text.BetweenDelimiters([Column1],"/","/"),2, "0"), type text)
in
#"Added Custom"
If this works for you, please mark it as the 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, I'm not sure if you just need the following code or something else.
= Date.EndOfMonth(DateTime.LocalNow())
Let me know if this is ok for you 🙂
Regards,
Happy to help!
Hi. You can change it like this:
= Date.ToText(Date.EndOfMonth(DateTime.Date(DateTime.LocalNow())), "yyyy-MM-dd")
Hope this helps,
Regards,
Happy to help!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.