Forum Discussion

FireFighter1017's avatar
FireFighter1017
Advocate III
10 months ago
Solved

Variable.Value() returns error 10418 "The variable ... could not be found"

I have created a variable library in a premium workspace named "Variables_Dataflows". In this library I have created a variable named "dfFactMroPurchasingDocuments" with value sets for DEV, QA and P...
  • tayloramy's avatar
    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
      Source

     

    If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.