cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Aleph18
Frequent Visitor

Display table with all possible combination of columns values

Hi,

 

I have a table of multiple columns that I will like to display showing all possible combinations of those values. Does anyone has an easy solution? Below a simple example of what I am trying to resolve. Thank you.

Capture.PNG

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Display table with all possible combination of columns values

Hi @Aleph18 

Create a new table, where Table1 is the original table you show on the left:

NewTable =
VAR AuxTable_ =
    CROSSJOIN ( DISTINCT ( Table1[Product] ); DISTINCT ( Table1[Type] ) )
RETURN
    ADDCOLUMNS (
        AuxTable_;
        "Quantity"; LOOKUPVALUE (
            Table1[Quantity];
            Table1[Product]; [Product];
            Table1[Type]; [Type]
        )
    )

View solution in original post

Anonymous
Not applicable

Re: Display table with all possible combination of columns values

You can use this DAX, though I always prefer to do this type of thing in Power Query:

Table 2 = 
ADDCOLUMNS(
CROSSJOIN( 
    SELECTCOLUMNS('Table', "Type",'Table'[Type]),
    SELECTCOLUMNS('Table',"Product",'Table'[Product]
    )
),
"Quantity", CALCULATE( SUM( 'Table'[Qty])))

Crossjoin Example.png

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III

Re: Display table with all possible combination of columns values

Hi @Aleph18 

Create a new table, where Table1 is the original table you show on the left:

NewTable =
VAR AuxTable_ =
    CROSSJOIN ( DISTINCT ( Table1[Product] ); DISTINCT ( Table1[Type] ) )
RETURN
    ADDCOLUMNS (
        AuxTable_;
        "Quantity"; LOOKUPVALUE (
            Table1[Quantity];
            Table1[Product]; [Product];
            Table1[Type]; [Type]
        )
    )

View solution in original post

Anonymous
Not applicable

Re: Display table with all possible combination of columns values

You can use this DAX, though I always prefer to do this type of thing in Power Query:

Table 2 = 
ADDCOLUMNS(
CROSSJOIN( 
    SELECTCOLUMNS('Table', "Type",'Table'[Type]),
    SELECTCOLUMNS('Table',"Product",'Table'[Product]
    )
),
"Quantity", CALCULATE( SUM( 'Table'[Qty])))

Crossjoin Example.png

View solution in original post

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors