Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Karthick1006
Frequent Visitor

Dynamically change exported csv file name through power automate in power bi desktop

I have a Power automate flow which exports the data in a visual using Run a query against a dataset.

Karthick1006_0-1746020069512.png

 I want to dynamically change the exported csv file name.
can someone explain how to achieve that?

 

Regards,

Karthick M

 

7 REPLIES 7
v-csrikanth
Community Support
Community Support

Hi  @Karthick1006
Sorry for the inconvenience caused.For deeper help on Power Automate actions and expressions, you may also want to ask in the Microsoft Power Automate Community:
https://community.powerplatform.com/t5/Microsoft-Power-Automate/ct-p/MPACommunity”

This way, you cover both Power BI and Power Automate experts.

Thanks and Regards,
Cheri Srikanth

 

v-csrikanth
Community Support
Community Support

Hi @Karthick1006 
Yes, it's possible to pass slicer selection dynamically to the “Run a query against a dataset” action. Follow these steps:

  • Create a DAX measure in Power BI using SELECTEDVALUE to capture the slicer selection.
    For example: SelectedCountry = SELECTEDVALUE('Country'[CountryName], "Default")

  • Add the Power Automate visual to the report and include the SelectedCountry measure in the fields section.

  • In Power Automate, set up the flow to accept the slicer value as an input parameter, like countryParam.

  • In the "Run a query against a dataset" action, replace any hardcoded values with the dynamic parameter using this format: TREATAS({ "@{triggerBody()?['countryParam']}" }, 'Country'[Value])

  • Save and test the flow to ensure it correctly picks up and uses the slicer value in the query.


If the above information helps you, please give us a Kudos and marked the Accept as a solution.
Best Regards,
Community Support Team _ C Srikanth.

 

Hi @v-csrikanth 

 

I have followed the steps as per your instruction but it is throwing the following error 

Karthick1006_3-1746799387671.png

 

 

Karthick1006_2-1746799288989.png

 

 

Regards,

Karthick M

 

v-csrikanth
Community Support
Community Support

Hi @Karthick1006 
Thank you for being part of the Microsoft Fabric Community.

By following these below steps, you can dynamically change the exported CSV file name based on user selections in Power BI Desktop using Power Automate.

  1. First add the Power Automate visual to your report.
  2. Link it to a flow that uses the "Run a query against a dataset" action to export data.
  3. Ensure you have a slicer or filter for the country and create a DAX measure to capture the selected country, like SelectedCountry = SELECTEDVALUE('Country'[CountryName], "Default").
  4. Pass the SelectedCountry measure to your Power Automate flow.
  5. In the flow, use this to build the file name, combining the timestamp and country name,
  6. for example, FileName = concat(triggerOutputs()?['headers']['x-ms-file-last-modified'], '_', triggerOutputs()?['headers']['x-ms-file-name']).
  7. Finally, use the "Create file" action to export the data to a CSV with the dynamic name. Add a timestamp to ensure unique file names and test the flow to confirm it works.

If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.

Hi @v-csrikanth, your solution worked, I appreciate your effort to help me out.

 

Also, I do have one more question, in the step Run a query against a dataset is there anyway 

we can pass a dynamic value based on slicer selection (The same value we passed for dynamic file name)?

Here in the below example you can see the country name Japan is static, I want to pass the slicer selection value (the same selection we passed for file name change). Can you please help me with this?

Karthick1006_0-1746792363318.png

 

Regards,

Karthick M

Karthick1006
Frequent Visitor

Hi @anilelmastasi 

 

Thanks for the quick response, here the sample data

 

Karthick1006_0-1746021993411.png

 

I want to name the file based on the country I select.
Currently I am naming the file with some prefix and and current timestamp 

but I want the file name to be dynamic based on my country selection.

anilelmastasi
Super User
Super User

Hello @Karthick1006 ,

 

How do you want to change dynamically? Can you give details of your output please?

Like OpcoData_[VARIABLE1][VARIABLE2].csv etc.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.