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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lgs2024
Regular Visitor

Using date variable in advanced editor returning empty value

Hi all

 

Fairly new to Power BI so hopefully I'm using the right terms etc. I found a similar thread with a different error but it doesn't appear to be resolved: https://community.fabric.microsoft.com/t5/Desktop/Defining-today-s-date-on-advanced-editor/td-p/2854...

 

I'm querying data from a REST API that requires today's date in a string format. Currently this is static so being updated manually, but now the dashboard is completed I'm trying to automate the date generation.

 

I have the below code which works fine by itself when I run it as its own query:

Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),0),"yyyy-MM-ddTHH:mm:ss")

 

When I use the above within the API query it seems to output nothing so the table outputs no data due to the missing date string:

lgs2024_0-1725358619471.png

 

 

I have tried tried inserting the code directly into the API query and also via a variable however I get the same result as above. I have tried escaping the quotes but this doesn't change the outcome either.

 

Here is a working (manual) example - the highlighted portion being what I need to automatically replace:

lgs2024_1-1725358843550.png

 

 

 

 

Thanks in advance for any assistance

 

 

4 REPLIES 4
danextian
Super User
Super User

Hi @lgs2024 ,

 

Did you replace the highlighted string directly with your pq formula or concatenate it with the rest of the strings? For example ...[" & pqformula & "]...  pqformula should be replaced by the actual formula.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Apologies for the ignorance, would you be willing to help with an expanded example?

 

I first tried it like this:

conditions = "doneFlag=false AND dateStart > [Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),0),""yyyy-MM-ddTHH:mm:ss"")]"


I'm not sure how I should be concatenating based on your example. The API formatting requires the date format to be within hard bracket characters [].

amitchandak
Super User
Super User

@lgs2024 , check how to pass dynamic parameter

 

https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-i...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Looks like a good approach - I have tried to use it in the format of the query I have but it doesn't appear to work. I have a considerable function performing the API query which allows the advanced editor to pass the conditions. Ideally I'm trying to find a way to evaluate the expression within double quotes without modifying the source function.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.