# DAX Exercise for fun 😁 Part 2

Dax Problem 2.pbix (17.2 KB)

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

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

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…

1 Like

Hahahahahaha, changing the rules afterwards

1 Like

Hehe

After @DavieJoe’s solution:

2 Likes

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…

• Brian
3 Likes

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

1 Like

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,

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

1 Like

@AntrikshSharma reviewing the solutions submitted so far…:

3 Likes

@BrianJ My reaction after each solution:

3 Likes

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

Also great to see @AntrikshSharma’s brain go

2 Likes

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

2 Likes

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

2 Likes
1 Like

Is this more what you were looking for?

• Brian
2 Likes

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.

Table 2 =
UNION(