Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
RichardMo
Frequent Visitor

Table structure/modelling issue - cannot get table structure right

I have a fact table like this: 

RichardMo_1-1690976258944.png

 

And I want to end up with a matrix visual like this:

RichardMo_4-1690977013702.png

But I can't figure out how to do it.

 

I can't unpivot the fact table as some of the date columns are calculated columns.

 

I have a date table with 1 active and multiple inactive relationships to the fact table. This has calcuated columns indicating last week/prev week/last month/previous month.

 

I have tried creating measures on the fact table but I couldn't figure out how to include all the stages in a measure; which meant I had to create seperate matrix visuals for each stage. Also there would have to be 100 or so measures as there are a lot more stages than the example above. I have also tried summarised tables but again I couldn't get the right structure to populate a matrix visual. 

 

Any tips appreciated.

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

HI , @RichardMo 

According to your description, you want to group by your column , but your columns contains the calculated columns and can not be unpivoted.

For your need, i think the best way is used dax to unpivot your table.

My test data is like this:

vyueyunzhmsft_0-1691121973586.png

 

We can click "New Table" and enter this:

Table 2 = UNION( SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Booking date] , "Type", "Booking"),
SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Session 1] , "Type", "Session1")   ,
SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Session 2] , "Type", "Session2")   ,
SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Test] , "Type", "Test") ,
SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Results] , "Type", "Results")
  )
 
 
Then we can get the result as follows and you can create some visual in your logic need:
vyueyunzhmsft_1-1691122442836.png

 

For more information, you can refer to :
powerbi - Is it possible to unpivot in Power BI using DAX? - Stack Overflow

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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-yueyunzh-msft
Community Support
Community Support

HI , @RichardMo 

According to your description, you want to group by your column , but your columns contains the calculated columns and can not be unpivoted.

For your need, i think the best way is used dax to unpivot your table.

My test data is like this:

vyueyunzhmsft_0-1691121973586.png

 

We can click "New Table" and enter this:

Table 2 = UNION( SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Booking date] , "Type", "Booking"),
SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Session 1] , "Type", "Session1")   ,
SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Session 2] , "Type", "Session2")   ,
SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Test] , "Type", "Test") ,
SELECTCOLUMNS('Table',"Person ID",[Person ID] , "City",[City] , "Category" , [Category] , "Date", [Results] , "Type", "Results")
  )
 
 
Then we can get the result as follows and you can create some visual in your logic need:
vyueyunzhmsft_1-1691122442836.png

 

For more information, you can refer to :
powerbi - Is it possible to unpivot in Power BI using DAX? - Stack Overflow

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.