Forum Discussion
Object level security - Paginated Report (missing column)
Hi Petra!
The missing column errors in Paginated are tricky and need to be handled by custom code which you would need to put in XML. You would need to put a check on column in your Dataset field level to overcome this.
Please refer to my article below on how to add custom code.
https://www.linkedin.com/pulse/power-bi-paginated-reports-custom-code-vb-abhinav-singh/
The code that youw ill need here is below. Please call this with your field that may go missing to catch the error on runtime!
public function GetValue(ByVal dataElement as Microsoft.ReportingServices.ReportProcessing.ReportObjectModel.Field) as String
If dataElement.IsMissing Then
Return " "
Else
Return dataElement.value
End If
End Function
Please let me know if you face issues implementing code.
Thanks!
Abhinav
Please mark as solution if this helps!
- PetrarteP5 years agoFrequent Visitor
Hi Abhinav,
thanks for the code, this could be very helpful workaround and I'll try it. My only concern is that Roles and OLS in PowerBI Dataset could be changed, so tomorrow some other field could be secured for some Role and I have no way of identifying it dynamically in the paginated report and prevent future crashes, unless I call this function for basically any field I am using in the report. That is why I was hoping that I can handle error on the DAX side somehow when fetching measure that for some users will not even exist.
I’ll for sure try this approach end let you know if I had any issues.
Thanks!
Petra
- AbhiSSRS5 years agoSolution Sage
Sure Petra!
And you may not bother about any perf impacts as I have widely tested this on missing fields with almost all having to use the code check. This worked even when the datset result goes missing altogether with no columns returned.
Thanks!
- PetrarteP5 years agoFrequent Visitor
Hi Abhinav,
I am strugling with the code and need help. Field for which I added expresion "=code.GetValue(Fields!Val_Opening_Balance_Amt.Value)" is rendering to "#error" even for me in Report Builder. Maybe it is because I am putting decimal type field and it is formatted in the matrix as number and not the string. Also I need to Return Nothing and not " ". Can you help to adjust the code? Thank you!