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
gaganbansal97
Frequent Visitor

Power Query - Accessing Cell Value to Power Query

I have this below line of code. I have made a table with the name DateInput and it has column Date 

 

Source = Sql.Database("-----", "---", [Query="select * FROM --- WHERE WeekEnd = 'Excel.CurrentWorkbook(){[Name="DateInput"]}[Content][Date]{0}'"]),

 

It's showing the error as Toek Comma Expected. While clicking on error it's highlighting DateInput

3 REPLIES 3
artemus
Employee
Employee

Since the item is a date type, you would need to wrap Excel.CurrentWorkbook(){[Name="DateInput"]}[Content][Date]{0} inside a Text.From

that is:

Text.From(Excel.CurrentWorkbook(){[Name="DateInput"]}[Content][Date]{0})

artemus
Employee
Employee

Try this:

Source = Sql.Database("-----", "---", [Query="select * FROM --- WHERE WeekEnd = '" & Excel.CurrentWorkbook(){[Name="DateInput"]}[Content][Date]{0} & "'"]),

After using this, it's showing below error

 

Expression.Error: We cannot apply operator & to types Text and DateTime.
Details:
Operator=&
Left=select * FROM ----
WHERE WeekEnd = '
Right=3/18/2023 12:00:00 AM

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