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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
AMZ
Regular Visitor

Power Query Syntax

Capture31.JPG

 

Using Images from a Database in Power BI - YouTube

 

Hello,

 

The above code retrieves certain columns from a table, one of which is a column containing images in binary content. The code transforms the images into text readable and understandable by Power BI and returns a table. However, when I try to execute it, I get an error that I don't understand. The Power Query editor asks me to put a parenthesis in place of the comma. I've tried, but it doesn't work. I don't understand why.

 

I've also attached, below the image, the link to the video from which I took the code.

 

Maybe the Power Query M language syntax has changed, because the video I saw is 3 years old.

 

Thanks in advance !

1 ACCEPTED SOLUTION

Ah, that's probably be the InputRow(xxx) parts. Try InputRow{xxx} instead since the parentheses make it think it's a function with an argument instead of an element from a list.

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

That particular error doesn't make sense to me. The only issue I see at first glance is that you have

CreatedDate = InputRow(InputCreateddatePosition)

instead of

CreatedDate = InputRow(InputCreatedDatePosition)

 

I don't get any errors with this code:

 

let
  //Entrée des paramètres fournis pour invoquer la fonction
  photoResult = (InputTable as table, InputBinaryPosition as number, InputNamePosition as number, InputCreatedDatePosition as number) as table =>
    let
      //Obtention des Listes d'images de la base de données
      Source = (InputTable),
      //Conversion de la table qui contient les images en liste
      ListToInput = Table.ToRows(Source),
      //Création de la fonction splitter
      SplitTextFunction = Splitter.SplitTextByRepeatedLengths(30000),
      //Conversion du contenu binaire en text et création d'images entrecoupées en 30000 lignes
      ConvertOneFile = (InputRow as list) =>
        let
          Binary      = InputRow(InputBinaryPosition),
          Name        = InputRow(InputNamePosition),
          CreatedDate = InputRow(InputCreatedDatePosition),
          BinaryText  = Binary.ToText(Binary, BinaryEncoding.Base64),
          SplitUpText = SplitTextFunction(BinaryText),
          AddFileName = List.Transform(SplitUpText, each {Name, CreatedDate, _})
        in
          AddFileName,
      //Passage en revue de toutes les photos et appel de la fonction ci-haute
      ConvertsAllRows = List.Transform(ListToInput, each ConvertOneFile(_)),
      //Combinaison des listes ensemble
      CombineLists = List.Combine(ConvertsAllRows),
      //Conversion du résultat en table
      ToTable = #table(type table [Name = text, CreatedDate = date, PhotoNonConformité = text], CombineLists),
      //Ajout de la colonne index à la table obtenue
      AddIndexColumn = Table.AddIndexColumn(ToTable, "Index", 0, 1)
    in
      AddIndexColumn
in
  photoResult

 

Thanks, it works. But when the function runs, I get the error below.

Capture32.JPG

An error occurred in the "GetTheEntireImage" request. Expression.Error : Sorry... We were unable to convert a List value to a Function value.
Details:

Value=[List]
Type=[Type]

Ah, that's probably be the InputRow(xxx) parts. Try InputRow{xxx} instead since the parentheses make it think it's a function with an argument instead of an element from a list.

Thanks ! It works.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors