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
mblonkatf
Frequent Visitor

Joined tables with filter returning all id's from connected table

Hi,

 

I'm trying to figure how to solve this problem, I hope one of you could help.

 

I have two tables.

table A

idmonthvalue
ajan   10
afeb15
bfeb3
cjan15
cfeb3
cmar6
capr70

 

Table B

idjanfebmarapr
a12151520
b5101010
c1551060
d20252015
e5103020

 

It is joined via id in a one(table B)-to-many(table A) relation. I would like to use the month column from table a as a filter. However I would also like to show up all id's from table B, so a, b, c, d, e and the sum of the values in regard to these months. Now I've been able to use a measure to select the values from column [jan] to the month selected from table A via the month filter. This measure is build up like this: 

if(SELECTEDVALUE('Table A'[Month])="jan";sum('Table B'[jan]);IF(SELECTEDVALUE('Table A'[Month])='feb";sum('Table B[feb]);   etc. 
 
This only returns the id's that the filter can return, which makes sense. Is there a way I could get all the values per id (a, b, c, d, e) from the jan column in Table B when I select "jan" from the month filter (table A)? And the same for feb,mar,etc.. 
 
Michel
1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@mblonkatf ,

 

In query editor, click on column jan, feb, mar and apr then click Transform-> Unpivot Columns, then modify the measures like:

Result =
IF (
    SELECTEDVALUE ( 'TableA'[Month] ) = "jan";
    SUM ( 'TableB'[Value] );
    IF ( SELECTEDVALUE ( 'TableA'[Month] ) = "feb"; SUM ( 'TableB'[Value] ) )
)

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yuta-msft
Community Support
Community Support

@mblonkatf ,

 

In query editor, click on column jan, feb, mar and apr then click Transform-> Unpivot Columns, then modify the measures like:

Result =
IF (
    SELECTEDVALUE ( 'TableA'[Month] ) = "jan";
    SUM ( 'TableB'[Value] );
    IF ( SELECTEDVALUE ( 'TableA'[Month] ) = "feb"; SUM ( 'TableB'[Value] ) )
)

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.