Skip to main content
Microsoft Idea

Power BI

Needs Votes

[BUG] Fix copy query to clipboard in PowerBI Desktop

Vote (3) Share
uli's profile image

uli on 16 Feb 2021 10:11:04

I already posted about this bug here: https://community.powerbi.com/t5/Issues/Copy-Query-to-Clipboard-bug/idc-p/1668914#M64359
Basically when copying a Query in the PowerQuery UI to clipboard, powerbi inserts it under content type text/html in an embedded XML in a HTML document (might be called microsoft mashup format). The problem is that the clipboard header is corrupt. One can investigate the clipboard content with a tool like https://www.nirsoft.net/utils/inside_clipboard.html . The resulting clipboard content when copying a query from powerbi desktop looks like this

Format:HTML Format
Version: 1.0
StartHTML: 0
EndHTML: 0
StartFragment: 0
EndFragment: 0


<?xml version="1.0" encoding="utf-8"?><Mashup xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/DataMashup"><Client>PBIDesktop</Client><Version&... Name="FaktArbeitszeiten"><Formula><![CDATA[let
Quelle = Excel.Workbook(Web.Contents("https://mogulargmbh.sharepoint.com/sites/mogularOrga/Freigegebene%20Dokumente/Zeiterfassung%20Uli/Ze...;), null, true),
tblArbeitszeiten_Table = Quelle{[Item="tblArbeitszeiten",Kind="Table"]}[Data],
#"Andere entfernte Spalten" = Table.SelectColumns(tblArbeitszeiten_Table,{"Tag", "Arbeitszeit", "Abwesenheit", "Kommentar"}),
#"Geänderter Typ" = Table.TransformColumnTypes(#"Andere entfernte Spalten",{{"Tag", type date}, {"Arbeitszeit", type time}, {"Abwesenheit", type text}}),
#"Hinzugefügte benutzerdefinierte Spalte" = Table.AddColumn(#"Geänderter Typ", "Benutzerdefiniert", each (Time.Hour([Arbeitszeit]) * 60 + Time.Minute([Arbeitszeit])) / 60),
#"Umbenannte Spalten" = Table.RenameColumns(#"Hinzugefügte benutzerdefinierte Spalte",{{"Benutzerdefiniert", "Arbeitszeit in h"}}),
#"Entfernte Spalten" = Table.RemoveColumns(#"Umbenannte Spalten",{"Arbeitszeit"}),
#"Gefilterte Zeilen" = Table.SelectRows(#"Entfernte Spalten", each [Arbeitszeit in h] <> null and [Arbeitszeit in h] <> 0 or [Abwesenheit] <> null),
#"Geänderter Typ1" = Table.TransformColumnTypes(#"Gefilterte Zeilen",{{"Arbeitszeit in h", type number}}),
#"Gefilterte Zeilen1" = Table.SelectRows(#"Geänderter Typ1", each [Tag] >= #date(2019, 10, 1))
in
#"Gefilterte Zeilen1"]]></Formula><LoadToReport>true</LoadToReport><IsParameterQuery>false</IsParameterQuery><IsDirectQuery>false</IsDirectQuery></Query></Items></Mashup>



As one can see the StartHTML and EndHTML as well as StartFragment and EndFragment values in the clipboard header are set to 0. This specification here https://docs.microsoft.com/en-us/windows/win32/dataxchg/html-clipboard-format says that these values must be set accordingly and not have zero values. As it appears when pasting this content into chrome it can recover these values and the paste works perfectly. Firefox on the other hand expects the clipboard to behave like specified and will return an empty string for mimetype text/html (because StartHTML and EndHTML are both zero, that makes sense).
This bug affects my application (powerqueryformatter.com) but also your own. Have a look at this gif:
https://www.dropbox.com/s/j89rgb9l0yef1p5/Clipbard-Problem-PowerBI.gif?dl=0
In this gif I perform the following steps:
1) In powerbi desktop copy a Query to clipboard
2) Go to powerbi service dataflow UI in **Google Chrome** and paste the query, works perfectly
3) Go to powerbi service dataflow UI in **Firefox** and paste the query, an error is displayed (because of the same bug I mentioned in my original post)
As you can see the paste query from clipboard is not working in firefox. And this is due to power bi not adheringto the clipboard HTML api specification.