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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
zhanna27
Frequent Visitor

Append dataset from powerbi service to sharepoint

Hello Community,

I'm struggling to append a dataset from powerbi service to an external source on my sharepoint. This sharepoint csv document  contains some archived data. I need to append new daily data each day to this .csv sharepoint document and I need to use my powerbi dataset for that which works fine and gives me the data for the day before yesterday. 

Is that possible ? 

I tried to write a code but it doesn't work :  

// Function to retrieve data from the API

let

    Limit = 10000,

    Query = (offset) =>

    let

        Source = Json.Document(Web.Contents(api site, [

            Query = [

                limit = Number.ToText(Limit),

                offset = Text.From(offset), // Convert offset to text

                auth = "some_token",

                startDate = Date.ToText(DateTime.Date(Date.AddDays(DateTime.LocalNow(), -2)), "yyyy-MM-dd"),

                endDate = Date.ToText(DateTime.Date(Date.AddDays(DateTime.LocalNow(), -1)), "yyyy-MM-dd")

            ]

        ]))

    in

        Source,

 

    // Load existing data from SharePoint .csv file

    SharePointCSV = Csv.Document(Web.Contents(update.csv), ",", QuoteStyle.None),

 

    // Determine if headers need to be included

    IncludeHeaders = Table.IsEmpty(SharePointCSV),

 

    // Call the function with an offset of 0

    Source1 = Query(0),

 

    // Merge new data with existing data

    MergedData = if Table.IsEmpty(SharePointCSV) then Source1 else Table.Combine({SharePointCSV, Source1}),

 

    // Convert to CSV text

    CsvText = Text.Combine({if IncludeHeaders then Text.Combine(Table.ColumnNames(MergedData), ",") else "", Text.Combine(List.Transform(Table.ToRecords(MergedData), each Text.Combine(Record.FieldValues(_), ",")), Character.FromNumber(13) & Character.FromNumber(10))}),

 

    // Upload the updated .csv back to SharePoint

    SharePointURL = sharepoint.update.csv,

    Upload = Web.Contents(SharePointURL, [Content=Text.ToBinary(CsvText), Headers=[#"Content-Type"="text/csv"]])

in

    Upload

 

Is threre a possibility maybe with incremental refresh but I I clearly see that no possible dataset saving possible on powerbi service and we have to use exterior storage. Do you confirm or maybe I miss something ? 

Thank you for your help. 

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @zhanna27 ,

Appending new data from Power BI to a SharePoint CSV file is not a native feature of Power BI service. Please consider using Power Automate or Power BI Desktop.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Hi @v-cgao-msft 

thank you for your reply. Can you please tell me how can we do this processs via powerbi Desktop? I need the data for the day before yesterday to be added to the file on my desktop every day and without headers. How can you automate it via powerbi desktop ? 

thank you.  

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors