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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Mariam1991
Helper II
Helper II

inner join

Hi, 

i need to join 2 tables in order to calculate a meaure in power BI 

i have 2 tables A and table B my aim is to add a measure in table A 

in sql :

select count(A.ID) from A 

inner join B on B.id=A.ID 

where B.status='payed'

Thank you in advance 

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @Mariam1991,

 

Could you try the formula below to see if it works in your scenario? Smiley Happy

New Column In Table A = COUNTROWS ( FILTER ( RELATEDTABLE ( 'TableB' ), 'TableB'[status] = "payed" ) )

 

Regards

View solution in original post

13 REPLIES 13
v-ljerr-msft
Employee
Employee

Hi @Mariam1991,

 

Could you try the formula below to see if it works in your scenario? Smiley Happy

New Column In Table A = COUNTROWS ( FILTER ( RELATEDTABLE ( 'TableB' ), 'TableB'[status] = "payed" ) )

 

Regards

hi 

thanks a lot , it works correctly but if i need to count just a distinct id

it doesn't work  

New Column In Table A = COUNTROWS ( FILTER ( RELATEDTABLE ( 'TableB' ), 'TableB'[status] = "payed" && 'tableB'[DATE_str] = 'TableA'[Date] ) ) it doesnt give me the possibility to add  =tableA[DATE] 😞

Hi @Mariam1991,

 

A little weird, the formula works fine on my test.

 

So could you try the formula below to see if it works? Smiley Happy

New Column In Table A =
VAR dateA =
    MAX ( 'TableA'[Date] )
RETURN
    COUNTROWS (
        FILTER (
            RELATEDTABLE ( 'TableB' ),
            'TableB'[status] = "payed"
                && 'tableB'[DATE_str] = dateA
        )
    )

 

Regards

Thank you so much !

Hi @Mariam1991,

 

Could you try the formula below to see if it works? Smiley Happy

New Column In Table A =
COUNTROWS (
    FILTER (
        RELATEDTABLE ( 'TableB' ),
        'TableB'[status] = "payed"
            && 'tableB'[DATE_str] = 'TableA'[Date]
    )
)

 

Regards

vanessafvg
Super User
Super User

create a relationship if there isn't already between table table a id to table b id in the relationship view

 

measurename = calculate(countrows(['table A'), 'Table B'[Status] = "payed")





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




thanks but i dont need a relation but an inner join between 2 table 

more than that i do the same measure and it doesn't work 😞

there isnt an inner join in power BI just a relationship inner join.jpg

Power BI is not the same as sql, creating a relationship has the same affect as an inner join, so once you have created the relationship(join) it should allow you to create the measure, have you tried and if so what error are you getting?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




okey ! there is no error but in result we observe that it doesn't take the join in consideration , like we calculate the count(id ) in table A without the relationship with table B ... between thanks for your feedback 

Can you show me how you wrote the measure?

also can you show me the screen shot of the join?

 

 

do you want to count unique id's or all the rows?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




the relationship is an inner join.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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