Pes*_*esa 4 powerbi powerbi-desktop
我想在PowerBi中加载图片,问题是图片比32kb大一点,所以它只显示图片的一部分。 有没有一些快速的方法可以绕过 PowerBi 限制并显示整个图片?
我从 activite 目录中获取图片,然后将二进制文件转换为文本,以便将它们设置为图片(使用以下公式:data:image/jpeg;base64)
Chriss Webb 写了一篇很棒的文章,在 Power BI 数据集中存储大图像,我将从中复制其中的要点,以防原始文章不可用。
\n\nPower Query 引擎可以加载到数据集中表的单个单元格中的文本值的最大长度为 32766 个字符 \xe2\x80\x93,超过此长度,文本将被静默截断。要解决此问题,您需要做的是将图像的文本表示形式拆分为跨多行存储的多个较小的文本值,每个值都小于 32766 个字符限制,然后在 DAX 度量中将它们重新组装数据已加载。
\n\n在M中拆分文本实际上并不难,但很难高效地完成。这里\xe2\x80\x99是一个M查询的示例,它从上面文件夹中的所有文件中读取所有数据并返回一个表:
\n\nlet\n //Get list of files in folder\n Source = Folder.Files("C:\\Users\\Chris\\Documents\\PQ Pics"),\n //Remove unnecessary columns\n RemoveOtherColumns = Table.SelectColumns(Source,{"Content", "Name"}),\n //Creates Splitter function\n SplitTextFunction = Splitter.SplitTextByRepeatedLengths(30000),\n //Converts table of files to list\n ListInput = Table.ToRows(RemoveOtherColumns),\n //Function to convert binary of photo to multiple\n //text values\n ConvertOneFile = (InputRow as list) =>\n let\n BinaryIn = InputRow{0},\n FileName = InputRow{1},\n BinaryText = Binary.ToText(BinaryIn, BinaryEncoding.Base64),\n SplitUpText = SplitTextFunction(BinaryText),\n AddFileName = List.Transform(SplitUpText, each {FileName,_})\n in\n AddFileName,\n //Loops over all photos and calls the above function\n ConvertAllFiles = List.Transform(ListInput, each ConvertOneFile(_)),\n //Combines lists together\n CombineLists = List.Combine(ConvertAllFiles),\n //Converts results to table\n ToTable = #table(type table[Name=text,Pic=text],CombineLists),\n //Adds index column to output table\n AddIndexColumn = Table.AddIndexColumn(ToTable, "Index", 0, 1)\nin\n AddIndexColumn\nRun Code Online (Sandbox Code Playgroud)\n\nHere\xe2\x80\x99s what the query above returns:
\n\n\n\nThe Pic column contains the split text values, each of which are less than the 32766 character limit, so when this table is loaded into Power BI no truncation occurs. The index column is necessary because without it we won\xe2\x80\x99t be able to recombine all the split values in the correct order.
\n\nThe only thing left to do is to create a measure that uses the DAX ConcatenateX() function to concatenate all of the pieces of text back into a single value, like so:
\n\nDisplay Image =\nIF(\n HASONEVALUE(\'PQ Pics\'[Name]),\n "data:image/jpeg;base64, " &\n CONCATENATEX(\n \'PQ Pics\',\n \'PQ Pics\'[Pic],\n ,\n \'PQ Pics\'[Index],\n ASC)\n )\nRun Code Online (Sandbox Code Playgroud)\n\n\xe2\x80\xa6set the data category of this measure to be \xe2\x80\x9cImage URL\xe2\x80\x9d:
\n\n\n\n\xe2\x80\xa6and then display the value of the image in a report:
\n\n\n\n\n| 归档时间: |
|
| 查看次数: |
12342 次 |
| 最近记录: |