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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Multiple relationships between tables in same expression

Hi! 

I'm stuck and would very much appreciate some help 🙂 

 

I have two tables that lookes like this, with two different relations: 

 

Tables.png

 

I have Measure 1: Number of rows = DISTINCTCOUNT('FactTable'[ID])

and then I would like to have another Measure 2:
Number of rows, Other department = 

CALCULATE([Number of rows];FILTER(FactTable;

"Physical team's department" <> "Responsible team's department")

 

But I don't know how to write this.... 

I have come so far that I think that the first part of the filter-expression should be: RELATED(DimOrganizationTable[Department]) <>..... But the second part I can't figure out. I'm thinking that it's maybe somthing with USERELATIONSHIP. But I can't get it to work. 

 

Thanks so much in advance! And have a nice weekend! 🙂

2 ACCEPTED SOLUTIONS
vivran22
Community Champion
Community Champion

Hello @Anonymous 

 

You may try this:

 

Other department =
CALCULATE (
    [Number of rows],
    FILTER (
        FactTable,
        RELATED ( dimOrgTable[Department] )
            <> LOOKUPVALUE (
                dimOrgTable[Department],
                dimOrgTable[Team_PK], FactTable[Responsible Team]
            )
    )
)

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Here's my take.  In the Fact Table, create a calculated column to bring over the Physical Teams's department column from the Dim Table

Column1 = RELATED(DimOrganizationTable[Department])

Column2 = LOOKUPVALUE(DimOrganizationTable[Department],DimOrganizationTable[Team_PK],FactTable[ID])

Now write this measure

=CALCULATE([Number of rows],FILTER(FactTable,[Column1]<>[Column2]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, you may create a measure as follows.

 

Count = 
CALCULATE(
    DISTINCTCOUNT(FactTable[ID]),
    FILTER(
        FactTable,
        LOOKUPVALUE(DimOrangnizationTable[Department],DimOrangnizationTable[Team_PK],FactTable[Physical team]) <> 
        LOOKUPVALUE(DimOrangnizationTable[Department],DimOrangnizationTable[Team_PK],FactTable[Responsible team])
    )
)

 

 

Resutl:

a1.png

 

Best Regards

Allan

 

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

Ashish_Mathur
Super User
Super User

Hi,

Here's my take.  In the Fact Table, create a calculated column to bring over the Physical Teams's department column from the Dim Table

Column1 = RELATED(DimOrganizationTable[Department])

Column2 = LOOKUPVALUE(DimOrganizationTable[Department],DimOrganizationTable[Team_PK],FactTable[ID])

Now write this measure

=CALCULATE([Number of rows],FILTER(FactTable,[Column1]<>[Column2]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
vivran22
Community Champion
Community Champion

Hello @Anonymous 

 

You may try this:

 

Other department =
CALCULATE (
    [Number of rows],
    FILTER (
        FactTable,
        RELATED ( dimOrgTable[Department] )
            <> LOOKUPVALUE (
                dimOrgTable[Department],
                dimOrgTable[Team_PK], FactTable[Responsible Team]
            )
    )
)

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

Anonymous
Not applicable

Thank you so much! 🙂 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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