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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Token identifier expected before if condition

(APIInsightsID as text)=>
(Counter as number)=>
let
Source = Excel.CurrentWorkbook(){[Name="Table23"]}[Content],
ID = Table.TransformColumnTypes(Source,{"App Insight ID ", type text}),
APIInsightsID = "",
Counter = 1,
if Counter > ID.RowCount
then APIInsightsID,
else
if ID."App Insight ID " != APIInsightsID
then
Counter+=1,
APIInsightsID = ID."App Insight ID ",
@CheckAPI
in
ID

 

Screenshot_2.png

Hello everyone I'm new in writing power queries, and I don't know why I get this error before if condition, do anyone know why? Kind regards Branislav

2 REPLIES 2
Anonymous
Not applicable

I want to iterate through a column, because while simply don't work, while is unrecognizable command.

v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need to assign the IF statement to a variable. And in your code, the red circles are not recognized by PowerQuery. 

 

vkkfmsft_0-1662433261888.png

 

Since I'm not sure of the exact output you want to achieve, I've only created a code that can be executed.

 

(APIInsightsID as text)=>
(Counter as number)=>
let
Source = Table,
ID = Table.TransformColumnTypes(Source,{"App Insight ID ", type text}),
APIInsightsID = "",
Counter = 1,
condition = if Counter > ID[Index]{0} then APIInsightsID 
            else if ID[App Insight ID] <> APIInsightsID then Counter+1
                else APIInsightsID = ID[App Insight ID]

in
condition

 

Best Regards,
Winniz

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.