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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Applicable88
Impactful Individual
Impactful Individual

Cannot spot Syntax failure/list min query

Hello,

I made a calculated column for this table:

11.05.2021Tuesday11234
12.05.2021Wednesday11235
13.05.2021Thursday11236
14.05.2021Friday11237
15.05.2021Saturaday01238
16.05.2021Sunday01239
17.05.2021Monday0null
18.05.2021Tuesday0null
19.05.2021Wednesday11242
20.05.2021Thursday11243
21.05.2021Friday11244
22.05.2021Saturaday01245
23.05.2021Sunday01246
24.05.2021Monday11247
25.05.2021Tuesday11248
26.05.2021Wednesday11249

 

Whatever day today is I want a calculated column to tell me the next productive workday =1. But only the next one, not further into the future:

Someone helped me a lot and provided me this query, but it might still has a syntax failure in it?

 

NextDay = List.Min(Table.SelectRows(Ordertable, each [ProductiveWorkday] = 1 and [OutBoundDate] > Date.From(DateTime.LocalNow()))[OutBoundDate])

 

I only get a error message.

Thank you very much in advance.

Best. 

 

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

This is a bit of a guess.  Replace 

Ordertable

in the formula with the previous step name  like ......      #"whatever"

View solution in original post

10 REPLIES 10
HotChilli
Super User
Super User

A cyclic reference is when A refers to B which refers to A and so on   or  even A refers to A (refers to A ...)

In Power Query a table is a sequence of query steps so in this case the last query step referred to the table name (which included the last query step) so it was cyclic.

The general advice is that each query step should act on the previous step.  That's not always true but it's a reasonable starting point.

Got it. Thanks for the explanation @HotChilli 

watkinnc
Super User
Super User

You may wish to wrap each if clause in parentheses so there is not chance of PQ getting confused, like this:

([ProductiveWorkday] = 1) and ([OutboundDate] > Date.From(DateTime.LocalNow()))

 

 


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Hi @watkinnc , thanks again for your effort. I also tried to leave the ProductiveWorkday out completely. Didn't help. But I think the tip of @HotChilli is going into the right direction. 

HotChilli
Super User
Super User

This is a bit of a guess.  Replace 

Ordertable

in the formula with the previous step name  like ......      #"whatever"

Hey @HotChilli, thanks so much... this was it!

It was a perfect "guess":)

I really want to learn from this mistake, so can you explain

 why it doesn't work with the orginal table name but with the #"StepName" ?

 

I also want to mention that the ProductiveWorkdays column is originally from a separated mastercalendar

that I joined with the maintable so I can use this as a condition for my statement. I don't know if that plays a role? 

HotChilli
Super User
Super User

what's the error?

no syntax error announced when I input it. but the calculated column state the typical error on every row. so no results. alll the column stated in the function do exist. I clicked on them in the right panel instead of writing myself. 

Click in a cell with the error and it will display under the table.

oh, thank you.

there it is, i translate in english:

Failure in the query 'Ordertable'.Expression.Error: While making the evaluation a cyclical reference where found. 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors