Forum Discussion
Variable.Value() returns error 10418 "The variable ... could not be found"
- 10 months ago
Hi FireFighter1017 ,
In Dataflow Gen2, the Power Query editor does not resolve Variable Library values at design time, so Variable.Value("$(/**/Library/Variable)") often throws 10418 in the editor even when the variable exists. Variables are resolved at run time. Also, Variable Libraries are only supported in Dataflow Gen2 with CI/CD, not in Dataflow Gen1. See Microsoft’s docs and notes here: Use Fabric variable libraries in Dataflow Gen2 (Preview).
- Use Dataflow Gen2 with CI/CD (not Gen1) and keep the Variable Library in the same workspace as the dataflow. Docs
- During authoring, call Variable.ValueOrDefault so the editor can evaluate a fallback; at refresh time Fabric will use the real variable value. Docs
- Make sure your identifier matches this exact format (display names, including spaces):
$(/**/LibraryName/VariableName) - Test by running the dataflow (Publish + Refresh). Don’t rely on the editor preview for variables. Docs
Example M you can drop in
// Works in authoring (fallback) and resolves at run time let TableName = Variable.ValueOrDefault( "$(/* */*/Variables_Dataflows/dfFactMroPurchasingDocuments)", "dfFactMroPurchasingDocuments_DevFallback" // match the variable's data type ), Source = SomeConnectorFunction( TableName ) in SourceIf you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.
Hi FireFighter1017,
There's use cases for both deployment pipeline rules and variable libraries, but I typically lean towards using only variable libraries as you are describing.
If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.
Hi tayloramy ,
Yeah I guess until Microsoft finally implements variables for both Gen1 Dataflows and Datasets we'll have to continue using deployment rules.
The funny thing is you can't go through CI/CD with Gen 2 Dataflows without using variables. They aren't supported for deployment rules.