Forum Discussion
Power Automate - "Run a query against a dataset" - missing columns from Power BI semantic model
Hi PetterR
You're using a Power Automate flow that runs every two hours to export data from a Power BI semantic model to a CSV file in SharePoint. The flow uses the "Run a query against a dataset" action to execute a DAX query, and then passes the result to "Create CSV table" and "Create file." The dataset has 15 columns, but you've observed that the generated CSV sometimes contains only 13 or 14 columns—specifically, columns that are sparsely populated (with data in less than 1% of rows) are occasionally missing. This behavior suggests that there’s a form of implicit optimization or sampling occurring somewhere in the process, likely during the transformation of the DAX output to a CSV table. Based on your testing, sorting the data to bring non-blank values to the top ensures that the sparse columns are included in the output, which indicates that Power Automate or the underlying dataset action may be performing a shallow sample (possibly first 500 rows) to infer the schema and structure of the CSV. Unfortunately, this kind of optimization behavior is not explicitly documented by Microsoft, and there is no official setting to disable it directly in Power Automate.
To ensure consistent column inclusion, aside from sorting, your best workaround is to explicitly coerce each expected column to a non-null default, such as adding a dummy first row with all expected fields initialized (e.g., to 0 or blank text). Another option is to manually define a consistent schema by transforming the dataset into a fixed table structure before passing it to "Create CSV table," possibly using a Power Automate expression or an intermediate step (like a formatted JSON table or manually mapping the fields). This forces Power Automate to always recognize all columns regardless of content. In summary, while this appears to be a sampling-based optimization within the flow, it cannot currently be turned off, and your best alternatives are sorting, pre-filling, or schema enforcement.