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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
wuyuansheng
New Member

Dynamic Parameter, Table Name

 

 

 

 

let
pvDate =
if Date.DayOfWeek(PriceDate) = 0 then
Date.AddDays(PriceDate, -6)
else if Date.DayOfWeek(PriceDate) = 1 then
Date.AddDays(PriceDate, -6)
else if Date.DayOfWeek(PriceDate) = 2 then
Date.AddDays(PriceDate, -6)
else if Date.DayofWeek(PriceDate) = 3 then
Date.AddDays(PriceDate, -6)
else
Date.AddDays(PriceDate, -4),

yyyyMM = DateTime.ToText(pvDate, "yyyyMM"),
yyyyMMdd = DateTime.ToText(pvDate, "yyyy-MM-dd"),
Source = Sql.Database("localhost", "CSWebChecksWebsite", [Query="Select axdgn202305.ClientFTP As [Client FTP], PriceValue From axdgn202305, AxiomClients where AxiomClients.clientFTP = axdgn202305.ClientFTP and PriceDate = '20230515' and PriceSource = 'priced' and AxiomClients.checksEnabled = 1"])
in
Source

 

 

I have the above query in direct query mode which is working fine. The date is fixed, once I change to the following code, it would complain of error. PriceDate is a parameter which I intend to display a date slicer for user to pick a date. Something todo once this is fixed.

 

 

Source = Sql.Database("localhost", "CSWEBChecksWebsite", [Query="Select LOWER(axdgn" & yyyyMM & ".ClientFTP) As [Client FTP], PriceValue From axdgn" & yyyyMM & ", AxiomClients where AxiomClients.clientFTP = axdgn" & yyyyMM & ".ClientFTP and PriceDate = '" & yyyyMMdd & "' and PriceSource = 'priced' and AxiomClients.checksEnabled = 1"])

 

 

 The data would load fine, but the apply step yields the following error. Any idea how to resolve the issue?

wuyuansheng_0-1693134998555.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@wuyuansheng , check dynamic M parameters

 

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters

 

https://www.youtube.com/watch?v=ilTeVH2Cwck

 

https://www.youtube.com/watch?v=L-wqwzj0-Xo

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

1 REPLY 1
amitchandak
Super User
Super User

@wuyuansheng , check dynamic M parameters

 

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters

 

https://www.youtube.com/watch?v=ilTeVH2Cwck

 

https://www.youtube.com/watch?v=L-wqwzj0-Xo

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.