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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nestuser
New Member

Change data source of a chart

Hello all!

 

I want to duplicate a chart but changing the data source from inside the same spreadsheet (different sheets, same table formats). Where do I find this option? i have found change data source but i can't arrive to select the table or sheet i want.

 

Thank u so much!

 

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @Nestuser ,

 

There isn’t an option to change sheets from the data sources directly in Power BI. There is a way which could implement it using parameters in Power Query.  In this way, you have to make the format of each sheet you want to change the same, like the number and type of columns . Then, while changing the value of  parameters, the item of source will be changed automatically. 

  1. Copy and paste Table 1 in Power Query .

0.png

  1. Click Home --> Manage Parameters -->New --> Choose the values of Sheet  you want to change.

1.jpg

  1. Right click Table1(2) -->choose Advanced Editor ---> change the value of Item equals parameter you created.

 

The Item is using parameters you created and the kind is changed  to “Sheet”.

3.jpg4.jpg

  1. Remove the top row, then you get the result.  Click Home-->Remove Rows

5.jpg6.png

There is the M code you can reference.

let

    Source = Excel.Workbook(File.Contents("D:\case\change data sources.xlsx"), null, true),

    Table1_Table = Source{[Item=#"data sources",Kind="Sheet"]}[Data],

    #"Changed Type" = Table.TransformColumnTypes(Table1_Table,{{"Column1", type date}, {"Column2", type date}, {"Column3", type datetime}, {"Column4", type date}, {"Column5", type datetime}}),

    #"Removed Top Rows" = Table.Skip(#"Changed Type",1)

in

    #"Removed Top Rows"

 

 

Best Regards,

Xue Ding

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-xuding-msft
Community Support
Community Support

Hi @Nestuser ,

 

There isn’t an option to change sheets from the data sources directly in Power BI. There is a way which could implement it using parameters in Power Query.  In this way, you have to make the format of each sheet you want to change the same, like the number and type of columns . Then, while changing the value of  parameters, the item of source will be changed automatically. 

  1. Copy and paste Table 1 in Power Query .

0.png

  1. Click Home --> Manage Parameters -->New --> Choose the values of Sheet  you want to change.

1.jpg

  1. Right click Table1(2) -->choose Advanced Editor ---> change the value of Item equals parameter you created.

 

The Item is using parameters you created and the kind is changed  to “Sheet”.

3.jpg4.jpg

  1. Remove the top row, then you get the result.  Click Home-->Remove Rows

5.jpg6.png

There is the M code you can reference.

let

    Source = Excel.Workbook(File.Contents("D:\case\change data sources.xlsx"), null, true),

    Table1_Table = Source{[Item=#"data sources",Kind="Sheet"]}[Data],

    #"Changed Type" = Table.TransformColumnTypes(Table1_Table,{{"Column1", type date}, {"Column2", type date}, {"Column3", type datetime}, {"Column4", type date}, {"Column5", type datetime}}),

    #"Removed Top Rows" = Table.Skip(#"Changed Type",1)

in

    #"Removed Top Rows"

 

 

Best Regards,

Xue Ding

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.