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

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

Reply
Batman020
New Member

Data Format Error in Powerbi Service

I am Getting the Following Error while refreshng in powerBi service . I have a bunch of file all are coming from the sharepoint folders.But from where can i check this error it doesnot state the document name and all . Please can anyone help !! 

Data source error: DataFormat.Error: Xml processing failed. Either the input is invalid or it isn't supported. (Internal error: Reference to undeclared entity 'ndash'. Line 10, position 19.). . The exception was raised by the IDbCommand interface.

Thanks

5 REPLIES 5
v-pgoloju
Community Support
Community Support

Hi @Batman020,

 

Thank you for reaching out to the Microsoft Fabric Community, and special thanks to @tayloramy  and @djurecicK2  for their prompt and helpful responses.

 

Thanks for the clarification. As @tayloramy  mentioned, could you please confirm whether you're using Excel files stored on SharePoint or XML files as your data source? This will help us determine if the issue is related to the connector being used.

 

Thanks & Regards,

Prasanna Kumar

Batman020
New Member

But i am using the the sharepoint file connecter in my powerbi desktop it all works fine in the dekstop as expected but as soon as in the service it crashes with this error on refresh , And actually i have a lot of sheets in my excel file and the data is also huge so how do i find that ndash and replace , can u guide me if i am using the wrong connected for it which is causing the error 
Thanks 

 

Hi @Batman020

 

Sorry, I'm now confused. Are you using XML files as your source, or are you using Excel files?  

tayloramy
Community Champion
Community Champion

Hi @Batman020,

 

You’re hitting an XML parser error during refresh because one of the files coming from SharePoint contains an HTML entity (–) inside text that Power BI is trying to parse as XML. In XML, entities like – are not defined unless a DTD declares them, so the parser stops with “Reference to undeclared entity ‘ndash’…”.

 

  1. Find the bad file by wrapping the parse step in try ... otherwise inside the Transform File function so the file Name and Error are surfaced.
  2. Fix or pre-clean: replace – (and similar) with a hyphen before parsing, or use Html.Table if the file is HTML (not XML).
  3. Publish and refresh again.

Refs: try ... otherwise | SharePoint Folder connector | Xml.Tables | Html.Table


A) Diagnostics to pinpoint the file

let
  Source      = SharePoint.Files("https://contoso.sharepoint.com/sites/YourSite", [ApiVersion = 15]),
  KeepCols    = Table.SelectColumns(Source, {"Name","Extension","Content"}),
  LikelyTypes = Table.SelectRows(KeepCols, each List.Contains({".xml",".xlsx",".xls",".html",".htm"}, Text.Lower([Extension]))),
  TryParse    = Table.AddColumn(
                  LikelyTypes, "ParseResult",
                  each try
                        if [Extension] = ".xml" then Xml.Tables([Content])
                        else if List.Contains({".html",".htm"}, Text.Lower([Extension])) then Html.Table([Content], {{"Dummy", "body"}})
                        else if List.Contains({".xlsx",".xls"}, Text.Lower([Extension])) then Excel.Workbook([Content], true)
                        else null
                      otherwise null
                ),
  HasError    = Table.AddColumn(TryParse, "HasError", each Value.Is([ParseResult], type error)),
  ErrorText   = Table.AddColumn(HasError, "ErrorText", each if [HasError] then try Error.Reason([ParseResult]) otherwise "Unknown error" else null),
  Diagnostics = Table.SelectRows(ErrorText, each [HasError] = true)
in
  Diagnostics

B) Clean entities before Xml.Tables

(entityText as text) as text =>
let
  Map = {
    {"–","-"},{"—","-"},{" "," "},{"‘","'"},{"’","'"},
    {"“","""},{"”","""},{"&","&"}
  },
  Cleaned = List.Accumulate(Map, entityText, (state, pair) => Text.Replace(state, pair{0}, pair{1}))
in
  Cleaned

Usage:

let
  AsText    = Text.FromBinary([Content], TextEncoding.Utf8),
  CleanText = @CleanEntities(AsText),
  BackToBin = Text.ToBinary(CleanText, TextEncoding.Utf8),
  XmlParsed = Xml.Tables(BackToBin)
in
  XmlParsed

C) If it’s HTML, use Html.Table instead of Xml.Tables

Html.Table([Content], {{"All", "//*"}})

 

If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.

djurecicK2
Super User
Super User

Hi  @Batman020 , 

The error "Power BI Reference to undeclared entity 'ndash'" indicates that the XML data you are attempting to load into Power BI contains an HTML entity, specifically – (en dash), which is not a pre-defined entity in XML.
Explanation:
  • XML vs. HTML Entities: 
    While HTML defines many named entities like –,  , ©, etc., XML only predefines a limited set of entities: <, >, &, ', and ". Any other named entity in an XML document must be explicitly declared within a Document Type Definition (DTD) or replaced with its numerical character reference.
  • Power BI and XML: 
    When Power BI attempts to parse XML data, it expects well-formed XML. If it encounters a named entity like – that is not declared or is not one of the five predefined XML entities, it throws an "undeclared entity" error.
    Solutions:
    • Modify the Source XML:
      • Replace with the actual character: The most straightforward solution is to replace – with the actual en dash character (–) in the source XML data.
      • Use the numerical character reference: Alternatively, replace – with its numerical character reference, which is – (hexadecimal) or – (decimal).
      • Declare the Entity in a DTD (More Complex):
        • If you have control over the XML generation and need to use named entities, you can declare them in a DTD associated with the XML file. This approach is generally more involved and might not be feasible if you are consuming external XML feeds.
        • Pre-process the XML data (if direct source modification is not possible):
          • If you cannot modify the source XML, you might need to pre-process the data before loading it into Power BI. This could involve using a scripting language (like Python) to read the XML, replace the problematic entities, and then save the corrected XML for Power BI to consume.
            Example of replacing in M (Power Query):
            If the data is loaded into Power Query, you could add a step to replace the entity:
            Code
             
            = Table.ReplaceValue(Source, "–", "–", Replacer.ReplaceText, {"YourColumnName"})
            Replace "YourColumnName" with the actual name of the column containing the XML data or the text with the – entity.
             
            This answer was partially generated by AI

Helpful resources

Announcements
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.