Forum Discussion

cviciano7707's avatar
cviciano7707
Regular Visitor
10 months ago
Solved

Fabric Gen2 Dataflow: Variable.ValueOrDefault Not Retrieving Active Value from Variable Library

Hi everyone,   I have created a Variable Library named Test, which contains a variable called TestVar. In my Gen2 Dataflow, I'm referencing this variable using the Variable.ValueOrDefault("$(/**/Te...
  • MJParikh's avatar
    10 months ago

    Hi cviciano7707,

    I hit this before. Your dataflow is resolving the variable, but it is running with the library’s Default value set. That is why you always see Filename_Default.xlsx.

    Key points

    1. On-demand runs in the workspace use the library’s Default value set.

    2. Dataflow Gen2 picks an alternative value set only when you bind or override it at run time.

    3. Variable.ValueOrDefault falls back to the second argument if the library or value set is not bound for that run.

    What to do
    A. Quick proof

    • In Variable Library, switch the Default value set to QA.

    • Run the dataflow on-demand.

    • You should now see the QA file name. Switch back after testing.

    B. Proper runtime binding

    • Trigger the dataflow from a Pipeline.

    • In the Dataflow Gen2 activity, open Runtime settings, select Variable library, choose the value set, then run.

    • Email alerts or Teams actions are optional.

    C. Deployment pipelines

    • Use deployment rules to map the target stage to the desired value set, so Dev uses Default, QA uses QA, Prod uses Prod.

    D. Authoring hygiene

    • In the dataflow, add a test step:

       
      = Variable.Value("$(/**/Test/TestVar)")

      Confirm the preview matches the chosen value set after a pipeline-triggered run.

    • Keep the library and the dataflow in the same workspace.

    • Avoid duplicate library names across workspaces. If duplicates exist, use a fully qualified path tied to the workspace ID.

    Common pitfalls

    • Expecting on-demand runs to follow QA or Prod. They follow Default.

    • Forgetting to set the value set on the Pipeline activity.

    • Caching during authoring. Use Refresh preview after changing the value set.

    • Missing library permissions for the runtime identity.