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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
kasife
Helper V
Helper V

counting by joining tables


Hi guys,
I'm having trouble coming up with a solution. I have the following measure that counts and joins my tables that are related through the broker ID. It turns out that in these tables there is information from 2 systems, so it can happen that 1 broker has 2 IDs, so the count is doubled. Is there the possibility of adjusting this measurement so that it performs this union using the broker ID, but gives me a different count using the broker name?
Thank you in advance.

 

COUNTROWS(DISTINCT(UNION(
    SELECTCOLUMNS(_leads,"Broker",[idcorretor]),
    SELECTCOLUMNS(_pastas,"B",[idcorretor]),
    SELECTCOLUMNS(_ccvs,"B",[idcorretor]),
    SELECTCOLUMNS(_repasses,"B",[idcorretor]))))

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @kasife ,

 

In this select you do not have any name so you cannot make a count based on the name.

 

When you refer that the tables are related based on broker do you have a separate that identifies each broker and is ID?

If yes you could try something similar to this:

Count Brokers =
VAR _selectedBroker =
    DISTINCT (
        UNION (
            SELECTCOLUMNS ( _leads, "Broker", [idcorretor] ),
            SELECTCOLUMNS ( _pastas, "B", [idcorretor] ),
            SELECTCOLUMNS ( _ccvs, "B", [idcorretor] ),
            SELECTCOLUMNS ( _repasses, "B", [idcorretor] )
        )
    )
VAR _brokerstable =
    FILTER ( BrokersTable, BrokersTable[idcorretor] IN _selectedBroker )
RETURN
    COUNTROWS ( DISTINCT ( SELECTCOLUMNS ( _brokerstable, [name] ) ) )

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @kasife ,

 

In this select you do not have any name so you cannot make a count based on the name.

 

When you refer that the tables are related based on broker do you have a separate that identifies each broker and is ID?

If yes you could try something similar to this:

Count Brokers =
VAR _selectedBroker =
    DISTINCT (
        UNION (
            SELECTCOLUMNS ( _leads, "Broker", [idcorretor] ),
            SELECTCOLUMNS ( _pastas, "B", [idcorretor] ),
            SELECTCOLUMNS ( _ccvs, "B", [idcorretor] ),
            SELECTCOLUMNS ( _repasses, "B", [idcorretor] )
        )
    )
VAR _brokerstable =
    FILTER ( BrokersTable, BrokersTable[idcorretor] IN _selectedBroker )
RETURN
    COUNTROWS ( DISTINCT ( SELECTCOLUMNS ( _brokerstable, [name] ) ) )

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix Thanks for the answer.
I don't have another table, and my dimension table is related to the fact tables by broker id

kasife_0-1714408025357.png

 

Hi @kasife 

 

The other table I refer is the broker table that you use has a dimension.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank you so much @MFelix . it worket.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors