Forum Discussion

k_umesh's avatar
k_umesh
Frequent Visitor
11 months ago
Solved

power query Dynamic pivoting and automate data refresh

I need to pivot JSON data and dynamically add columns during each data refresh in a Fabric semantic model. This functionality only works when I trigger a manual refresh using the Refresh button; sche...
  • Anonymous's avatar
    Anonymous
    11 months ago

    Hi k_umesh ,

    The refresh issue happens because the query uses dynamic pivoting, which means Power Query creates new columns automatically based on whatever JSON keys appear in the data. This works during manual refresh, but scheduled or API refresh cannot handle changing columns, so it fails with errors saying a column doesn’t exist. To fix this, you can use a fixed list of column names instead of letting Power Query create them dynamically, so the table structure stays the same every time. Another easy option is to avoid pivoting in Power Query and let a Matrix visual in Power BI do the pivoting, which keeps the data stable and makes scheduled refresh safe. If your data comes from a database, you can also pivot in SQL by creating a view with a stable set of columns. If you need pivoted columns in your dataset, the best way to go is to stick with a fixed list of pivot columns. That way, your schema stays consistent and you won't run into refresh issues.
    https://learn.microsoft.com/en-us/power-bi/connect-data/refresh-data#data-refresh-and-schema-refresh