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

Creating a combined column from two separate tables in a new table with DAX

Hello

I have two tables with the following example data:

Table 1

GridNumber of Failures
apple1
banana2
cherry3
date4

 

Table 2

GridNumber of Failures
orange3
yellow1
blue2
purple3

 

I want to create a table through only Dax functions that shows the following

Table 3:

Number of FailuresGrid
1apple, yellow
2blue, banana
3purple, orange, cherry
4

date

  

 

How would I do this so then I could create a table visual showing table 3? I would like some relationship set up such that if I also filtered with slicers on my visual they wold work as well. For example if I looked for only apple in table 1. Thank you for your help!

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Anonymous 

 

Table = 
VAR _tbl1 = 
DISTINCT(
    UNION(
        DISTINCT('Table 1'[Number of Failures]),
        DISTINCT('Table 2'[Number of Failures])
    )
)
VAR _result = 
    ADDCOLUMNS(
        _tbl1,
        "Grid", 
        VAR _num = [Number of Failures]
        VAR _result1 = CONCATENATEX(FILTER('Table 1', 'Table 1'[Number of Failures] = _num ), 'Table 1'[Grid], ", ")
        VAR _result2 = CONCATENATEX(FILTER('Table 2', 'Table 2'[Number of Failures] = _num ), 'Table 2'[Grid], ", ")
        VAR _delimiter = IF( NOT ISBLANK(_result1) && NOT ISBLANK(_result2), ", ", "")         
        RETURN
            _result1 & _delimiter & _result2
    )
RETURN
    _result

 

Here is a link to download a sample solution file:
Creating a combined column from two separate tables in a new table with DAX 2022-08-09.pbix

2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Showcase Report – Contoso By SpartaBI

Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

View solution in original post

5 REPLIES 5
saravanan_p
Resolver III
Resolver III

Kindly attach a test data . Need more clarity.

saravanan_p
Resolver III
Resolver III

Thats awesome Sparta. Cheers!!

@saravanan_p thank you 🙂
@Anonymous Please don't forget to accept the previous message as a solution for community visibility.

P.S. Check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. Please give it a thumbs up over there if you liked it 🙂
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543

Good morning

I wanted to know if it is possible to relate two matrices, that is, I have two tables, one of percentages and one of quantities, both tables you can see area 1 and area 2. I would need that if I click on table 1 to see the areas 2 that that table has, the same thing happens with the other table, that is, if I expand one the other expands.

It's possible?

Thank you!

SpartaBI
Community Champion
Community Champion

@Anonymous 

 

Table = 
VAR _tbl1 = 
DISTINCT(
    UNION(
        DISTINCT('Table 1'[Number of Failures]),
        DISTINCT('Table 2'[Number of Failures])
    )
)
VAR _result = 
    ADDCOLUMNS(
        _tbl1,
        "Grid", 
        VAR _num = [Number of Failures]
        VAR _result1 = CONCATENATEX(FILTER('Table 1', 'Table 1'[Number of Failures] = _num ), 'Table 1'[Grid], ", ")
        VAR _result2 = CONCATENATEX(FILTER('Table 2', 'Table 2'[Number of Failures] = _num ), 'Table 2'[Grid], ", ")
        VAR _delimiter = IF( NOT ISBLANK(_result1) && NOT ISBLANK(_result2), ", ", "")         
        RETURN
            _result1 & _delimiter & _result2
    )
RETURN
    _result

 

Here is a link to download a sample solution file:
Creating a combined column from two separate tables in a new table with DAX 2022-08-09.pbix

2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Showcase Report – Contoso By SpartaBI

Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

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.