Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I am looking to create a table that looks like the above. I can create the metrics but I can only get it to display as all columns or all rows. I can't figure out if there's a way to make some metrics rows and other columns. Any help is appreciated.
Are the year values to remain static or do you need them to be dynamic? (For example current year and previous year)
Proud to be a Super User!
Paul on Linkedin.
They would remain static - though I have more than this year and last year date attributes I could create tables for the various views as needed
Here is one way.
Please bear in mind this exampe is built on a simple fact table. You will need to adapt the measures and tables to suit your model
1) create a new independent table for the Years and Diff using:
2) Create the measures for each value using the following syntax :
Volume =
VAR MX =
CALCULATE (
MAX ( 'Columns Table'[Column] ),
FILTER (
ALLSELECTED ( 'Columns Table'[Column] ),
'Columns Table'[Column] <> "Diff"
)
)
VAR MinY =
CALCULATE (
MIN ( 'Columns Table'[Column] ),
FILTER (
ALLSELECTED ( 'Columns Table'[Column] ),
'Columns Table'[Column] <> "Diff"
)
)
VAR MAXYC =
CALCULATE (
SUM ( FactTable[Volume] ),
FORMAT ( FactTable[Year], "General Number" ) = MX
)
VAR MINYC =
CALCULATE (
SUM ( FactTable[Volume] ),
FORMAT ( FactTable[Year], "General Number" ) = MinY
)
RETURN
SWITCH (
SELECTEDVALUE ( 'Columns Table'[Column] ),
MX, MAXYC,
MinY, MINYC,
MAXYC - MINYC
)
3) Create a matrix visual and add the columns table field to the columns bucket and add each measure to the values bucket.
In the formatting pane, under Values, turn on the option "Show on Rows":
Select the visual and set the required values in the filter pane:
And this is the result:
I've attached a sample PBIX file
Proud to be a Super User!
Paul on Linkedin.
Hi, @Katie123
According to your description, I think you can create a Dax table using DATATABLE() function. The syntax allows you to define each column name and data type, and then add data values to it.
Like this:
Table =
DATATABLE (
" ", STRING,
"2020", INTEGER,
"2021", INTEGER,
"Diff", INTEGER,
{
{ "Volume", 100, 300, 200 },
{ "Sales", 1000, 1500, 500 },
{ "Cost", 100, 150, 50 },
{ "Margin", 900, 1350, 450 }
}
)
Reference:DATATABLE function - DAX | Microsoft Docs
Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.
Best Regards,
Community Support Team _ Janey
Hello @Katie123
If you could send a sample .pbix that demonstrates what you are looking to get. It would really help to provide you with a quick solution.
Regards
Kumail Raza
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 66 | |
| 44 | |
| 43 | |
| 36 | |
| 23 |
| User | Count |
|---|---|
| 196 | |
| 125 | |
| 105 | |
| 77 | |
| 56 |