Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Solved! Go to Solution.
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.
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.
That seems to be more of a PowerApp question - maybe post in their forum? Microsoft Power Platform Community Forum Thread
Note: Patch can only update an existing record or create a new one. It cannot delete records.
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!