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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Sunkari
Responsive Resident
Responsive Resident

Required code to remove the reports present in Power BI Embedded Workspace

 

 

Any body have code to remove the reports present in Power BI Embedded Workspace collection.

 

Please provide your inputs so that i will try implement functionality the code.

 

 

 

 

 

 

 

 

9 REPLIES 9
Anonymous
Not applicable

You can right click on the report you want to remove and click on "Hide". That can be done only through the Power Bi desktop then you can re-publish.

Greg_Deckler
Community Champion
Community Champion

I do not see anything here that indicates you can programatically remove reports:

 

https://msdn.microsoft.com/en-us/library/mt711507.aspx

 

Unless removing a data set removes associated reports.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

From the sample tool I used from this blog entry,  a "dataset" is the .pbix files so it has the data & reports. 

 

This is a great blog.

How to Embed Report in PowerBI Azure Service

http://www.mostafaelzoghbi.com/2016/04/power-bi-embedded-step-by-step.html

Source: https://github.com/Azure-Samples/power-bi-embedded-integrate-report-into-web-app/

   https://github.com/melzoghbi/PowerBIEmbeddedSimplified

Anonymous
Not applicable

You can delete a report by deleting the associated dataset.

I've managed to do this by adding the following code to Program.cs of the Sample app :

 

I added this code to the switch :

 

                    case '8':
                        if (string.IsNullOrWhiteSpace(workspaceCollectionName))
                        {
                            Console.Write("Workspace Collection Name:");
                            workspaceCollectionName = Console.ReadLine();
                            Console.WriteLine();
                        }

                        if (string.IsNullOrWhiteSpace(workspaceId))
                        {
                            Console.Write("Workspace ID:");
                            workspaceId = Console.ReadLine();
                            Console.WriteLine();
                        }

                        var datasets = displayDatasets(workspaceCollectionName, workspaceId);
                        
                        Console.WriteLine("Choose which dataset to delete :");
                        string datasetId = Console.ReadLine();
                        await DeletePbixFile(workspaceCollectionName, workspaceId, datasetId);
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Report deleted successfully");

                        await Run();
                        break;

I created two methods that are called in the process :

The first one returns all the datasets (with their names and their ID) :

 

        static async Task<ODataResponseListDataset> displayDatasets(string workspaceCollectionName, string workspaceId)
        {
            // Create a dev token for deletion
            var devToken = PowerBIToken.CreateDevToken(workspaceCollectionName, workspaceId);
            using (var client = await CreateClient(devToken))
            {
                var datasets = client.Datasets.GetDatasets(workspaceCollectionName, workspaceId);
                foreach (Dataset set in datasets.Value)
                {
                    Console.WriteLine("Name : {0} : Id : {1}", set.Name, set.Id);
                }
                return datasets;
            }
        }

 The second one deletes the dataset that has the ID that is passed as parameter :

 

        static async Task DeletePbixFile(string workspaceCollectionName, string workspaceId, string datasetId)
        {
            // Create a dev token for deletion
            var devToken = PowerBIToken.CreateDevToken(workspaceCollectionName, workspaceId);
            using (var client = await CreateClient(devToken))
            {
                    var deletion = client.Datasets.DeleteDatasetById(workspaceCollectionName, workspaceId, datasetId);
            }
        }

Simply press 8 when prompted for a choice by the console, and then copy and paste the dataset ID of the dataset you which to delete (along with the report that comes with it).

 

It does work on my side, but do not hesitate to ask questions if it doesn't on your side.

 

Cheers Smiley Happy

 

 

 

Your article usefull for me. deleted the report file work fine but how to remove workspce ID?

thank you.

Anonymous
Not applicable

@karthikeyan I don't know if removing a workspace is possible. I tried to remove one but I didn't manage to do so Smiley Frustrated

@Anonymous Hi , thank you tired  friend.

Sunkari
Responsive Resident
Responsive Resident

Thanks man. I will check and let you know.

Can you provide me information related to removing dataset?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.