DAX Exercise for fun 😁 Part 2

Here is your data:
Dax Problem 2.pbix (17.2 KB)

image

You need to create a Calculated table that Unpivots the data using DAX:

image

Have fun! Make sure to blur your solutions.

Edit 1:

@DavieJoe’s solution made me realize I should make it a little difficult by adding a caveat. Now you can’t use SUMMARIZE or SUMMARIZECOLUMNS or any other projection function.

Edit 2:

@DavieJoe and @BrianJ are exempt from this but if you try to solve this problem then don’t use projection functions.

Hint: Use Context Transition, I want you to think more about a way to solve this using Context Transition.

3 Likes

You’re trying to destroy what is left of my brain @AntrikshSharma :exploding_head::exploding_head:

This might not be the most elegant of solutions

UNION(

SUMMARIZECOLUMNS('Table'[Index], 'Table'[Col 1]),

SUMMARIZECOLUMNS( 'Table'[Index], 'Table'[Col 2] ))
3 Likes

Nicely done and pretty quick looks like I need to increase the difficulty a little bit, to make people think a bit more… :smirk:

1 Like

Hahahahahaha, changing the rules afterwards :joy::joy::joy::+1:t2::+1:t2:

1 Like

Hehe

After @DavieJoe’s solution:
tenor

2 Likes

@AntrikshSharma ,

I have a feeling #2 was intended to lull us into a false sense of security. I suspect #3 is going to be a doozy… :smiley:

  • Brian
3 Likes

Wow this post turned out to be bit bad Lol. I should have made a caveat earlier about projection functions :dizzy_face: :sob:

1 Like

Hi @AntrikshSharma,

How’s this…

T0 = 
UNION( 
    ALL( Data[index], Data[Col 1]),
    ALL( Data[index], Data[Col 2])
)

Don’t know if ALL is allowed and yes,
also had SUMMARIZECOLUMNS, SUMMARIZE and SELECTCOLUMNS ready to submit :upside_down_face:

3 Likes

@Melissa Good one! I will alow everything now, but will wait if someone gets a solution with Context Transition, not because it is a complex way of doing the same thing but just want to push their limits :stuck_out_tongue:

1 Like

@AntrikshSharma reviewing the solutions submitted so far…:

flip

3 Likes

@BrianJ My reaction after each solution:

image

3 Likes

It’s great to see so many different ways to create this table!

Also great to see @AntrikshSharma’s brain go :exploding_head: :joy::+1:t2:

2 Likes

Don’t worry @Melissa …… @AntrikshSharma will just change the rules anyway :joy::joy::joy::joy::joy:

2 Likes

@DavieJoe haha, me to anyone giving a solution that I don’t like:
image

image

2 Likes

1 Like

@AntrikshSharma ,

Is this more what you were looking for?

  • Brian
2 Likes

Hey @AntrikshSharma

Here goes the solution

Table =

UNION

This text will be blurred(
SELECTCOLUMNS(Data,“Index”,Data[index],“Value”,Data[Col 1]),

SELECTCOLUMNS(Data,“Index”,Data[index],“Value”,Data[Col 2])

)

3 Likes

@BrianJ I was looking for something like this:

Table = 
GENERATE ( 
    DISTINCT ( Data[index] ),
    UNION ( 
        CALCULATETABLE ( DISTINCT ( Data[Col 1] ) ),
        CALCULATETABLE ( DISTINCT ( Data[Col 2] ) )
    )
)

But overall all good solutions.

4 Likes

@AntrikshSharma

After posting the solution here i saw your post on linkedin. I saw you wrote context transition there though you have written the same here in notes too but i missed it while reading.

Here goes another way of doing it with context transition.:wink:

Table 2 =
UNION(
ADDCOLUMNS(VALUES(Data[index]),“Value”,CALCULATE(MAX(Data[Col 1]))),
ADDCOLUMNS(VALUES(Data[index]),“Value”,CALCULATE(MAX(Data[Col 2])))
)

1 Like