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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
akumarche
Regular Visitor

how to use dynamic date on Pipeline Analytics powerbi query?

We are looking to publish some test results from ADO Pipeline analytics to powerBI. Below is the query that is available. However, we are currently “Hard Coding” the date and need to get either todays date or todays date -1 in {startdate} portion. Can you guys tell us how to do that?

https://analytics.dev.azure.com/{organization}/{project}/_odata/v4.0-preview/TestResultsDaily?
$apply=filter(
Pipeline/PipelineName eq ‘{pipelineName}’
And Date/Date ge {startdate} --------This is being hard coded today
And Workflow eq ‘Build’
)
/groupby(
(TestSK, Test/TestName),
aggregate(
ResultCount with sum as TotalCount,
ResultPassCount with sum as PassedCount,
ResultFailCount with sum as FailedCount,
ResultNotExecutedCount with sum as NotExecutedCount,
ResultNotImpactedCount with sum as NotImpactedCount,
ResultFlakyCount with sum as FlakyCount))
/filter(FailedCount gt 0)
/compute(
iif(TotalCount gt NotExecutedCount, ((PassedCount add NotImpactedCount) div cast(TotalCount sub NotExecutedCount, Edm.Decimal)) mul 100, 0) as PassRate

 

Source :
docs.microsoft.com/en-us/azure/devops/report/powerbi/sample-test-analytics-failed-tests?view=azure-devops&tabs=powerbi

 

I tried many solution in the internet like :

And Date/Date ge Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),-3), ‘yyyy-MM-dd’) 

 

FixedLocalNow()

 

Now()

 

and every time I get :

 

DataSource.Error: OData: Request failed: The remote server returned an error: (400) Bad Request. (VS403483: The query specified in the URI is not valid: An unknown function with name ‘DateTime.LocalNow’ was found. This may also be a function import or a key lookup on a navigation property, which is not allowed…)

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@akumarche , if this url is built like 

 

"URL"

then you can break and insert power query variables

"URL/Date="& Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),-3), ‘yyyy-MM-dd’)  & " "

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
akumarche
Regular Visitor

@amitchandak  thanks for quick reply.

 

I am not sure about breaking the url, its the first time I am using powerbi.

I am pulling the Pipeline reports from Azure devops.

docs.microsoft.com/en-us/azure/devops/report/powerbi/sample-test-summary-trend?view=azure-devops&tabs=powerbi

 

and below is the whole query, can you help me how to use dynamic {date} :

 

let Source = OData.Feed ("https://analytics.dev.azure.com/{organization}/{project}/_odata/v4.0-preview/TestRuns? $apply=filter(" &"Pipeline/PipelineName eq '{pipelineName}' "

&"and CompletedOn/Date ge {startdate}) "

&"/groupby((Workflow, CompletedOn/Date), "

&"aggregate( " &"ResultPassCount with sum as ResultPassCount, "

&"ResultNotExecutedCount with sum as ResultNotExecutedCount, "

&"ResultCount with sum as ResultCount, "

&"ResultNotImpactedCount with sum as ResultNotImpactedCount, "

&"ResultFailCount with sum as ResultFailCount)) "

&"/compute( " &"iif(ResultCount gt ResultNotExecutedCount, ((ResultPassCount add ResultNotImpactedCount) div cast(ResultCount sub ResultNotExecutedCount, Edm.Decimal)) mul 100, 0) as PassRate) " ,null, [Implementation="2.0",OmitValues = ODataOmitValues.Nulls,ODataVersion = 4]) in Source

 

amitchandak
Super User
Super User

@akumarche , if this url is built like 

 

"URL"

then you can break and insert power query variables

"URL/Date="& Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),-3), ‘yyyy-MM-dd’)  & " "

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak  any update on this.

I am stuck in these from weeks. Any help appriciated! 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (4,363)