Forum Discussion
Render data based on IF true condition
- 4 years ago
Hi Anonymous ,
Unfortunately, it is impossible to hide the measure by this way.
First, you want to show different data depend on the end user.
Row-level security (RLS) with Power BI can be used to restrict data access for given users. So RLS is the best choice. It is best to read through the entire text to implement RLS. userprincipalname() and username() are always used with RLS.
Second, username() and userprincipalname() are not support in calculate column and new table.
Third, username() and userprincipalname() can be used in measure but measure not support return a table. But measure can use table during calculation process. For example
Measure = VAR _table3_from_your_code = SELECTCOLUMNS( TimeReport, "Neukunden_Akquise_Systeme", TimeReport[Neukunden_Akquise_Systeme], "Neukunden_Akquise_Produkte", TimeReport[Neukunden_Akquise_Produkte], "User Name", TimeReport[User Name] ) RETURN COUNTROWS( _table3_from_your_code )This return number, and string all support.
Fourth, for detail of differences between columns and measures
https://insightsoftware.com/blog/calculated-columns-vs-measures/
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Sreenathv,
Unfortunately it is giving the same error message - any other thought ?
Is it a temporary table you are creating inside a measure? Otherwise, the calculated tables are generated during the data load/refresh. The "SELECTEDVALUE" and IF conditions are useful only when the user interacts with the report and you generate a measure using a temporary table in it. But once the table is generated during refresh/data load, whatever the user selects in a slicer or other visual, that's not gonna change the already calculated table. What is the scenario?
- Anonymous4 years agoNot applicable
Anonymous Thanks for the quick response.
I have the following table:
Function Department City Revenue TopManagers TD Sales Pune 1M [email protected]; [email protected]; [email protected] AD HR Mumbai 2M [email protected]; [email protected]; [email protected] TID Procurement Delhi 3M [email protected]; [email protected] My requirement is to check whether the CurrentUser logged-in user is one of the TopManagers, if so then show the data.
I am achieving this check with this simple IF operator (line 2) against the [WhoIsWatching] which is the USERPRINCIPALNAME() function, once the check is true then show the data else nothing.
Is it a temporary table you are creating inside a measure? => I m creating a new table from Modelling Menu > New Table.
- Anonymous4 years agoNot applicable
Anonymous
The calculated table is created even before the user signs in and consumes the report. So I don't think this approach of creating a table with data based on the USERPRINCIPALNAME() function will work.
However, you could use USERPRINCIPALNAME() as a part of your measures - something like
if (USERPRINCIPALNAME() in VALUES(TopManagers),Return figures, blank())Need to explore this usage.
- Anonymous4 years agoNot applicable
Anonymous I just checked and looks promising
However, I m getting stuck in the "Return figures" 😐 - how to return the data?
I tried the same way but no luck...please help!