cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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

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
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.

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

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
secondImage

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

secondImage

Power BI Women

Join our monthly meetings and learning sessions.

secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

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.

Top Solution Authors
Top Kudoed Authors