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("$(/**/Test/TestVar)", "filename_Default.xlsx") function.

 

The dataflow runs successfully without any errors, but it doesn't seem to retrieve the active value set in the Variable Library. Instead, it is retrieving the default value used in the function.

 

Both the Gen2 Dataflow (CI/CD) and the Variable Library are located in the same workspace, and to avoid any mismatches, I’ve created them in the root folder. The Gen2 Dataflow reads a table from a Lakehouse in another workspace and writes the data to a Warehouse table in the same workspace as the dataflow.

I'm using ticket https://community.fabric.microsoft.com/t5/Fabric-platform/Fabric-Gen2-Dataflow-Variable-Value-not-working-when-referencing/m-p/4832463 as a reference and have already reviewed all the points listed in it.

 

Has anyone run into this issue before? Is there a specific configuration or step I'm missing to ensure the dataflow picks up the active value from the library?

 

Screenshots are attached for reference.

 

Variable Library:

 

Gen2 Dataflow (CI/CD):

 

Datafalow refresh:

 

 

Table data (loaded by dataflow):

 

Thanks in advance for help!

  • 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.

2 Replies

  • 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.

    • cviciano7707's avatar
      cviciano7707
      Regular Visitor

      Hi MJParikh ,

       

      Thanks for replying.

      I followed the three steps you described under Quick proof, and it worked — everything is functioning properly now.

       

      I really appreciate your help.