Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
POSPOS
Post Partisan
Post Partisan

Create three tables based on different condition in Power BI

Hi All,

I have two tables, Base table and Transaction Table. Base table has a row level security based on user name.

I have to create three new tables based on these tables usig DAX:

Base Table :

User NameDCOrg
UAA00111205100
UAA00111215100
UAA001112251001
UAA001112351001
UAA001112451001
UAA001112551001
UAA00211206100
UAA00211216100
UAA002112851002
UAA002112951002
UAA002113051003
UAA002113161003
UAA00311415100
UAA003114251001
UAA003114351001

 

Transaction Table:

User NameDCOrgAmount
UAA00111205100100
UAA00111215100101
UAA001112251001102
UAA001112351001103
UAA001112451001104
UAA001112551001105
UAA00211206100106
UAA00211216100107
UAA002112851002108
UAA002112951002109
UAA002113051003110
UAA002113161003111
UAA00311415100112
UAA003114251001113
UAA003114351001114
UAA00411204100115
UAA00511405100116
UAA00611405100117

 

New table : Table 1

1. Based on the user , create a table based on the data they have access to from the base table. Eg: for UAA001, Table 1 will be

User NameDCOrgAmount
UAA00111205100100
UAA00111215100101
UAA001112251001102
UAA001112351001103
UAA001112451001104
UAA001112551001105


New table : Table 2

2. Based on the DC from Table 1, look for any additional "Org" in the transcation table that are not in Table 1. Here, we should not restrict to just the user who has logged in, will have to look at the entire table irrespective of the user.

 

eg: Here, 1120,1121,1122,1123,1124,1125 are the "DC" from Table 1, we look for the same "DC" in the transaction table for all the users and identify any additional "org" thats not in Table 1 . Org=6100,61003,4100 are not in Table 1.They should come in Table 2.

Below are the additional "Org" not in Table 1.

User NameDCOrgAmount
UAA00211206100106
UAA00211216100107
UAA00411204100115

Tabl 2: 

User NameDCOrgAmount
UAA00111206100213
UAA00111204100115

 

New table : Table 3

3. Based on the "Org" from Table 1, look for any additional "DC" in the transcation table that are not in Table 1. Here, we should not restrict to just the user who has logged in, will have to look at the entire table irrespective of the user.

 

eg: Here, 5100, 51001 are the "Org" from Table 1, we look for the same "Org" in the transaction table for all the users 

and identify any additional "dc" thats not in Table 1 . DC=1141,1142,1143,1140 are not in Table 1.They should come in Table 3.

Below are the additional "Org" not in Table 3.

 

User NameDCOrg 
UAA00111415100112
UAA001114251001113
UAA0011143

51001

114

UAA0011140

5100

116

UAA0011140

5100

117

then, Table 3 is : 

User NameDCOrg 
UAA00111415100112
UAA001114251001113
UAA0011143

51001

114

UAA0011140

5100

223

 

Can some one please advise on how this can be achieve. any help will be much appreciated.

 

 

3 ACCEPTED SOLUTIONS
rajendraongole1
Super User
Super User

Hi @POSPOS - implement the Base Table and Transaction Table are connected via the User Name, DC, and Org columns where necessary.
Apply row-level security (RLS) on the Base Table using DAX expressions for filtering based on the logged-in user (USERNAME()).

Define RLS roles on the Base Table to restrict access based on the logged-in user ([User Name] = USERNAME()).

 

This table is filtered to include only the rows from the Transaction Table that match the Base Table data for the logged-in user.

 

Table1 =
FILTER(
'Transaction Table',
'Transaction Table'[User Name] = USERNAME() &&
LOOKUPVALUE('Base Table'[DC], 'Base Table'[DC], 'Transaction Table'[DC]) <> BLANK() &&
LOOKUPVALUE('Base Table'[Org], 'Base Table'[Org], 'Transaction Table'[Org]) <> BLANK()
)

 

This table identifies rows in the Transaction Table where the DC matches any DC from Table 1 but includes Org values that are not present in Table 1.

 

Table2 =
FILTER(
'Transaction Table',
'Transaction Table'[DC] IN DISTINCT('Table1'[DC]) &&
NOT('Transaction Table'[Org] IN DISTINCT('Table1'[Org]))
)

 

table identifies rows in the Transaction Table where the Org matches any Org from Table 1 but includes DC values that are not present in Table 1.

 

Table3 =
FILTER(
'Transaction Table',
'Transaction Table'[Org] IN DISTINCT('Table1'[Org]) &&
NOT('Transaction Table'[DC] IN DISTINCT('Table1'[DC]))
)

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

anmolmalviya05
Super User
Super User

Hi @POSPOS, Please try to create new tables with below code:

Table-1:
Table1 =
FILTER(
ADDCOLUMNS(
'Transaction Table',
"IsInBaseTable",
COUNTROWS(
FILTER(
'Base Table',
'Base Table'[User Name] = 'Transaction Table'[User Name] &&
'Base Table'[DC] = 'Transaction Table'[DC] &&
'Base Table'[Org] = 'Transaction Table'[Org]
)
)
),
[IsInBaseTable] > 0
)


Table-2:
Table2 =
FILTER(
ADDCOLUMNS(
'Transaction Table',
"IsAdditionalOrg",
NOT(
COUNTROWS(
FILTER(
'Table1',
'Table1'[DC] = 'Transaction Table'[DC] &&
'Table1'[Org] = 'Transaction Table'[Org]
)
)
)
),
[IsAdditionalOrg] > 0
)

table-3:

Table3 =
FILTER(
ADDCOLUMNS(
'Transaction Table',
"IsAdditionalDC",
NOT(
COUNTROWS(
FILTER(
'Table1',
'Table1'[Org] = 'Transaction Table'[Org] &&
'Table1'[DC] = 'Transaction Table'[DC]
)
)
)
),
[IsAdditionalDC] > 0
)




View solution in original post

v-tsaipranay
Community Support
Community Support

Hi @POSPOS ,

 

Thanks for reaching out to the Microsoft fabric community forum.

 

To create three tables based on different condition in Power BI follow below step to meet your requirement.

Table 1: Create a table that includes data the user has access to from the Base Table.

For table1 use the below DAX Formula:

 

Table1 =

VAR CurrentUser = "UAA001" -- Replace with the current user dynamically

RETURN

FILTER(

    'Transaction Table',

    'Transaction Table'[User Name] = CurrentUser

vtsaipranay_0-1733912582280.png

Table 2: Create a table that includes additional “Org” values from the Transaction Table based on the “DC” values from Table 1.

For table2 use the below DAX Formula:

Table2 =
VAR Table1DCs = DISTINCT(SELECTCOLUMNS(FILTER('Transaction Table', 'Transaction Table'[User Name] = "UAA001"), "DC", 'Transaction Table'[DC]))
RETURN
FILTER(
    'Transaction Table',
    NOT 'Transaction Table'[Org] IN
        SELECTCOLUMNS(
            FILTER('Transaction Table', 'Transaction Table'[User Name] = "UAA001"),
            "Org", 'Transaction Table'[Org]
        ) &&
    'Transaction Table'[DC] IN Table1DCs
)
vtsaipranay_1-1733912716749.png

 

Table 3: Create a table that includes additional “DC” values from the Transaction Table based on the “Org” values from Table 1.

For table3 use the below DAX Formula:

 

Table3 =

VAR Table1Orgs = DISTINCT(SELECTCOLUMNS(FILTER('Transaction Table', 'Transaction Table'[User Name] = "UAA001"), "Org", 'Transaction Table'[Org]))

RETURN

FILTER(

    'Transaction Table',

    NOT 'Transaction Table'[DC] IN

        SELECTCOLUMNS(

            FILTER('Transaction Table', 'Transaction Table'[User Name] = "UAA001"),

            "DC", 'Transaction Table'[DC]

        ) &&

    'Transaction Table'[Org] IN Table1Orgs

)

vtsaipranay_2-1733912739367.png

I hope my suggestions give you good idea.


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thankyou.

 

View solution in original post

3 REPLIES 3
v-tsaipranay
Community Support
Community Support

Hi @POSPOS ,

 

Thanks for reaching out to the Microsoft fabric community forum.

 

To create three tables based on different condition in Power BI follow below step to meet your requirement.

Table 1: Create a table that includes data the user has access to from the Base Table.

For table1 use the below DAX Formula:

 

Table1 =

VAR CurrentUser = "UAA001" -- Replace with the current user dynamically

RETURN

FILTER(

    'Transaction Table',

    'Transaction Table'[User Name] = CurrentUser

vtsaipranay_0-1733912582280.png

Table 2: Create a table that includes additional “Org” values from the Transaction Table based on the “DC” values from Table 1.

For table2 use the below DAX Formula:

Table2 =
VAR Table1DCs = DISTINCT(SELECTCOLUMNS(FILTER('Transaction Table', 'Transaction Table'[User Name] = "UAA001"), "DC", 'Transaction Table'[DC]))
RETURN
FILTER(
    'Transaction Table',
    NOT 'Transaction Table'[Org] IN
        SELECTCOLUMNS(
            FILTER('Transaction Table', 'Transaction Table'[User Name] = "UAA001"),
            "Org", 'Transaction Table'[Org]
        ) &&
    'Transaction Table'[DC] IN Table1DCs
)
vtsaipranay_1-1733912716749.png

 

Table 3: Create a table that includes additional “DC” values from the Transaction Table based on the “Org” values from Table 1.

For table3 use the below DAX Formula:

 

Table3 =

VAR Table1Orgs = DISTINCT(SELECTCOLUMNS(FILTER('Transaction Table', 'Transaction Table'[User Name] = "UAA001"), "Org", 'Transaction Table'[Org]))

RETURN

FILTER(

    'Transaction Table',

    NOT 'Transaction Table'[DC] IN

        SELECTCOLUMNS(

            FILTER('Transaction Table', 'Transaction Table'[User Name] = "UAA001"),

            "DC", 'Transaction Table'[DC]

        ) &&

    'Transaction Table'[Org] IN Table1Orgs

)

vtsaipranay_2-1733912739367.png

I hope my suggestions give you good idea.


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thankyou.

 

anmolmalviya05
Super User
Super User

Hi @POSPOS, Please try to create new tables with below code:

Table-1:
Table1 =
FILTER(
ADDCOLUMNS(
'Transaction Table',
"IsInBaseTable",
COUNTROWS(
FILTER(
'Base Table',
'Base Table'[User Name] = 'Transaction Table'[User Name] &&
'Base Table'[DC] = 'Transaction Table'[DC] &&
'Base Table'[Org] = 'Transaction Table'[Org]
)
)
),
[IsInBaseTable] > 0
)


Table-2:
Table2 =
FILTER(
ADDCOLUMNS(
'Transaction Table',
"IsAdditionalOrg",
NOT(
COUNTROWS(
FILTER(
'Table1',
'Table1'[DC] = 'Transaction Table'[DC] &&
'Table1'[Org] = 'Transaction Table'[Org]
)
)
)
),
[IsAdditionalOrg] > 0
)

table-3:

Table3 =
FILTER(
ADDCOLUMNS(
'Transaction Table',
"IsAdditionalDC",
NOT(
COUNTROWS(
FILTER(
'Table1',
'Table1'[Org] = 'Transaction Table'[Org] &&
'Table1'[DC] = 'Transaction Table'[DC]
)
)
)
),
[IsAdditionalDC] > 0
)




rajendraongole1
Super User
Super User

Hi @POSPOS - implement the Base Table and Transaction Table are connected via the User Name, DC, and Org columns where necessary.
Apply row-level security (RLS) on the Base Table using DAX expressions for filtering based on the logged-in user (USERNAME()).

Define RLS roles on the Base Table to restrict access based on the logged-in user ([User Name] = USERNAME()).

 

This table is filtered to include only the rows from the Transaction Table that match the Base Table data for the logged-in user.

 

Table1 =
FILTER(
'Transaction Table',
'Transaction Table'[User Name] = USERNAME() &&
LOOKUPVALUE('Base Table'[DC], 'Base Table'[DC], 'Transaction Table'[DC]) <> BLANK() &&
LOOKUPVALUE('Base Table'[Org], 'Base Table'[Org], 'Transaction Table'[Org]) <> BLANK()
)

 

This table identifies rows in the Transaction Table where the DC matches any DC from Table 1 but includes Org values that are not present in Table 1.

 

Table2 =
FILTER(
'Transaction Table',
'Transaction Table'[DC] IN DISTINCT('Table1'[DC]) &&
NOT('Transaction Table'[Org] IN DISTINCT('Table1'[Org]))
)

 

table identifies rows in the Transaction Table where the Org matches any Org from Table 1 but includes DC values that are not present in Table 1.

 

Table3 =
FILTER(
'Transaction Table',
'Transaction Table'[Org] IN DISTINCT('Table1'[Org]) &&
NOT('Transaction Table'[DC] IN DISTINCT('Table1'[DC]))
)

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.