cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lenerius
Helper I
Helper I

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
Super User I
Super User I

Hello @Lenerius 

 

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 III
Super User III

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, @Lenerius 

 

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 III
Super User III

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

vivran22
Super User I
Super User I

Hello @Lenerius 

 

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

Thank you so much! 🙂 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

April Update

Check it Out!

Click here to read more about the April 2021 Updates!

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.