I'm trying to create a new table that will act as a page-level security filter on a Power BI report. I have two tables, doc_class and comp_class, which are routinely updated and do all the calculations I need. I simply need a new table that will assign page access based on an OwnerID's presence in the doc_class table.
Any OwnerID in the doc_class table needs access to two Power BI pages: Doctor and Doctor ROI ALL OwnerIDs in the comp_class table need access to a different set of two pages: Practice and Practice ROI. All OwnerIDs in doc_class are also in comp_class, if that makes any difference. Page levels needs to each have their own row, and that is the part that is tripping me up.
Here are example tables (IDs only--the other data does not matter in this use case):
doc_class:
| OwnerID |
| -------- |
| 2 |
| 3 |
comp_class:
| OwnerID |
| --------|
| 1 |
| 2 |
| 3 |
| 4 |
Expected result:
| OwnerID | page |
| -------- | ------------ |
| 1 | Practice |
| 1 | Practice ROI |
| 2 | Doctor |
| 2 | Doctor ROI |
| 2 | Practice |
| 2 | Practice ROI |
| 3 | Doctor |
| 3 | Doctor ROI |
| 3 | Practice |
| 3 | Practice ROI |
| 4 | Practice |
| 4 | Practice ROI |
2条答案
按热度按时间kx5bkwkv1#
aiazj4mn2#
Alternative solution.
Union
removes duplicates so you can take advantage of that. Also usingcross apply
makes code easier to read.