Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I am trying to build a report where I am getting data from an API. This API needs a body for the todate and fromdate. I am able to pass today's date and last 30 days.
I want to input this "30" from the user selection. I want a tile slicer filter with 7,15,30,60.. values and when 7 is selected, it should fetch last 7 days data and respectively for all others.
This is the code I am using to call the API with a parameter made in Power query called as DayNo.
let
today = DateTime.LocalNow(),
// Construct the URL with query parameters
url = "<<url>>",
queryString = "?fromdate=" & DateTime.ToText(today - #duration(DaysNo,0,0,0),"yyyy-MM-dd") & "&todate=" & DateTime.ToText(today,"yyyy-MM-dd"),
fullUrl = url & queryString,
// Retrieve data from the web source
source = Json.Document(Web.Contents(fullUrl)),
in
source
Dynamic M Query parameters only work with Direct Query data sources. Your API data source is not Direct Query.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 10 | |
| 6 | |
| 5 | |
| 4 | |
| 2 |