Forum Discussion

markmsc's avatar
markmsc
Icon for Resolver I rankResolver I
1 year ago
Solved

Using embedded Power App to delete a row in a report datasource

Hello all.  Pretty simple question here, really, but I've not turned up an example solution.  Would be grateful for a pointer.

 

I have a relatively simple Power BI report that displays the content of a database table, with a few filters and such applied.  On the report is an embedded Power App that allows report viewers to edit the database table data, or insert and save a new row if needed.  

 

That is all working fine.  For various reasons, users were not permitted to delete rows from the table so the Power App has never supported that.  This restriction is now removed, so the app must let them delete.

 

The app itself is conceptually similar to the example app laid out in Understand canvas-app forms.  Accordingly, I scrolled down to the Delete a Record section in that document and attempted to do the same thing.  Add a button for Deletes, and then set the OnSelect property to (quoting that document(:

 

Remove( 'Ice Cream', Gallery1.Selected )

 

In this example case from the doc, "Ice Crream" is a SharePoint list.  In my app I am working with a database table that is connected to the from via its DataSource property.  So instead of "Ice Cream", I do, e.g.

 

Remove('schema_name.table_name',Gallery1.Selected)

 

The parser has no issue with me specifying the datasource in there.  Instead, it objects to  me trying to pass in Gallery1.selected, saying: "Incompatible type. The collection can't contain values of this type."

 

So which half of the arguments is my problem here?  Should I be specifying something other than the datasource for the first parameter?  Or something other than Gallery1.Selected for the row that is to be removed from the datasource?

 

(Or should I just skip using Form functions and try to use Patch in the button's OnSelect instead?)

 

Thank you.

  • Just for completeness, I solved it.  The underlying table is a single-column primary key, identity type.  Accordingly, it wasn't being passed into the app and so I couldn't do anything with it there.  I modfied the report-app definition to incliude the key, and then changed my Remove function in the app to include LookUp by the key:

     

    Remove('schema_name.table_name', LookUp('schema_name.table_name', mytableID = Gallery1.selected.mytableID))

     

    and that works fine.

     

3 Replies

    • markmsc's avatar
      markmsc
      Icon for Resolver I rankResolver I

      Yes, my mistake on Patch and also accidentally posting to the wrong place.  I steered here out of habit and didn't even realize it!

  • Just for completeness, I solved it.  The underlying table is a single-column primary key, identity type.  Accordingly, it wasn't being passed into the app and so I couldn't do anything with it there.  I modfied the report-app definition to incliude the key, and then changed my Remove function in the app to include LookUp by the key:

     

    Remove('schema_name.table_name', LookUp('schema_name.table_name', mytableID = Gallery1.selected.mytableID))

     

    and that works fine.