Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Embed Full Image into power bi

Dear Community   i Am Trying to Embed an image to a report, but when i try to make the following query to get the full image i get this error:     "#table is invalid constant value"   I am get...
  • v-jingzhang's avatar
    5 years ago

    Hi Anonymous 

     

    At the first glance, I found some typos in your M codes.

     

    I followed Patrick's video to create a function to get the images. Below are my codes for your reference. Also attach the pbix file at the bottom. Hope this helps.

    let
        //Input parameter to call the function
        picresult = (InputTable as table, InputBinaryZBPosition as number, InputKeyNameZBPosition as number, InputKeyZBPosition as number) as table =>
    let
        //Get list of images from Database
        Source = (InputTable),
        //Converts table that contains images to list
        ListToInput = Table.ToRows(Source),
        //Creates Splitter function
        SplitTextFunction = Splitter.SplitTextByRepeatedLengths(30000),
    
        //Function to convert binary of photo to multiple
        //text values
        ConvertOneFile = (InputRow as list) =>
            let
                BinaryIn = InputRow{InputBinaryZBPosition},
                RegionName = InputRow{InputKeyNameZBPosition},
                CountryKey = InputRow{InputKeyZBPosition},
                BinaryText = Binary.ToText(BinaryIn, BinaryEncoding.Base64),
                SplitUpText = SplitTextFunction(BinaryText),
                AddFileName = List.Transform(SplitUpText, each {RegionName, CountryKey, _})
            in
                AddFileName,
        //Loops over all photos and calls the above function
        ConvertAllRows = List.Transform(ListToInput, each ConvertOneFile(_)),
        //Combines lists together
        CombineLists = List.Combine(ConvertAllRows),
        //Converts results to table
        ToTable = #table(type table[RegionName=text, CountryKey=number, Pic=text],CombineLists),
        //Adds index column to output table
        AddIndexColumn = Table.AddIndexColumn(ToTable, "Index", 0, 1)
    in
        AddIndexColumn
    in 
        picresult

     

    Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as the solution to help other members find it.