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

Measure issue joining 2 tables

Hello,

 

I'm just starting with Power BI and I have an issue.

I uploaded 2 tables :

 

Table 1

 

Group IDID
GPID_AID_1
GPID_AID_1
GPID_AID_2
GPID_BID_3
GPID_CID_4

 

Group ID aggregates some IDs - It's possible to get several ID/Group ID

 

Table 2

IDvalue
ID_110
ID_215
ID_35
ID_420

 

It exists a value for each ID - In this table there is only one ID (no duplicates)

 

I would like to have as a final result :

 

Expected Table

 

Group IDIDValue IDValue Group ID
GPID_AID_11035
GPID_AID_11035
GPID_AID_21535
GPID_BID_355
GPID_CID_42020

 

 

 

Value ID is the ID value found in the Table 2 and Value Group ID is the value aggregrated by Group ID i.e for the 3 first lines (GPID_A) = 10 + 10 + 15

 

 

In Power BI I added a relationship between Table1 (ID) and Table2 (ID) with the following cardinality (*,1)

 

However when I add the value in my dashboard I obtain this result (it seems it's the total result without duplicates) :

 

Result in Power BI

 

Group IDIDSomme de Value
GPID_AID_150
GPID_AID_150
GPID_AID_250
GPID_BID_350
GPID_CID_450

 

Could you help me?

 

Thanks in advance

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Anonymous 
step 1: create a relationship between the two:

SpartaBI_1-1652096843850.png


Add these Calculated Columns to Table 1 (the table on the many side):

Value For ID = RELATED('Table 2'[value])
Total Group =
VAR _g = 'Table 1'[Group ID]
RETURN
CALCULATE(
SUM('Table 1'[Value For ID]),
REMOVEFILTERS('Table 1'),
'Table 1'[Group ID] = _g
)
This is the result:
SpartaBI_2-1652096918044.png

 

In case it answered your question, please accept it as a solution to help the other members find it more quickly. Appreciate Your Kudos 💪
Showcase Report – Contoso By SpartaBI 
Website Linkedin Facebook 
This is SpartaBI!

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

For the Value ID I found a solution :

 

Value ID =
CALCULATE (
SUM ( 'Table 2'[Value] ),
FILTER ( 'Table 2', 'Table 2'[ID Table 2] IN VALUES ( 'Table 1'[ID]) )
)
speedramps
Super User
Super User

Option 1:-

Use the the deduplication command in the Table1 query editor

create 1:m relationship to table2

 

Option 2:-

delete relationship from table1 to table2
copy table1 to DimID tabele

Use the the deduplication command in the DimID query editor

create 1:m relations to table1 and table2

 

 

I helped you now please help me with kudos.

Please click thumbs up and accepts as solution buttons.

One problem per ticket please.

If you you need to revise the problem then please accept this solution and raise a new ticket. 

Thanks ‌‌

 

SpartaBI
Community Champion
Community Champion

@Anonymous 
step 1: create a relationship between the two:

SpartaBI_1-1652096843850.png


Add these Calculated Columns to Table 1 (the table on the many side):

Value For ID = RELATED('Table 2'[value])
Total Group =
VAR _g = 'Table 1'[Group ID]
RETURN
CALCULATE(
SUM('Table 1'[Value For ID]),
REMOVEFILTERS('Table 1'),
'Table 1'[Group ID] = _g
)
This is the result:
SpartaBI_2-1652096918044.png

 

In case it answered your question, please accept it as a solution to help the other members find it more quickly. Appreciate Your Kudos 💪
Showcase Report – Contoso By SpartaBI 
Website Linkedin Facebook 
This is SpartaBI!
Anonymous
Not applicable

It works. Thanks for your help

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.