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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rahul-opp
Helper I
Helper I

How to swap columns and values in matrix

Hello
I am using Matrix to show data.
for example, 2 metrics Sales and Ad Spend with days data.
Currently it look like


Setting:
Rows = Product name
Columns = Date
Values = Sales, Ad Spend ( values could be more like conversion, ACoS )

 

pv-img1.jpeg

But we want to show data as following
pv-img2.jpeg

Is it possible to show data as per second image, I mean main metrics will be on top and dates below each metric? How?

1 ACCEPTED SOLUTION

Hi @rahul-opp ,

 

Your problem is that this are column on your model and not measures.

 

Change the Values measure to:

ValueMeasure =
SWITCH (SELECTEDVALUE(Parameter[Paramete Order]),
0, SUM('Master ASIN Join'[Page View]),
1, SUM('Master ASIN Join'[Clicks]))

Should work.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

16 REPLIES 16
rahul-opp
Helper I
Helper I

I have created parameter with fields Page Views and clicks and added it in Columns and below that added Date
but it is showing 
ParamMeasure = {
("Clicks", NAMEOF('Test Table'[Clicks]), 0),
("Page Views", NAMEOF('Test Table'[Page Views]), 1)
}

Here is how it appeared.
Screenshot 2024-07-24 at 11.35.34 AM.png

I have started learning Power Bi recently. So correct me if I made any implementation mistake.

From my initial question, in Matrix I was able to show "Date"( added to columns ) on top and below each date, fields / measures are appearing by adding them to values ( First image )

But I want reverse it where "Dates" should appear below each measure/field.  ( Second Image )

Are there any other ways to create the view?




Hi @rahul-opp ,

 

Just change the order of the columns place first the dates and then the parameters


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix , I already tried that, but no use. This is how it looks.
Screenshot 2024-07-24 at 2.51.56 PM.png

I am able to create first image in my question by simply placing fields as below ( which I don't want ), But I want show "fields" on top and whichever date range under each "field".
Screenshot 2024-07-24 at 2.58.31 PM.png

There has to be some trick. 

Hi @rahul-opp ,

 

Try and create the following measure:

Measure 3 = SWITCH(SELECTEDVALUE(Parameter[Parameter Order]), 0, [Measure], 1 , [Measure 2])

The values of the measures should match the ones in the the parameter table:

MFelix_0-1721817506455.png

 

Now the table should be setup like this:

 

MFelix_1-1721817575538.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix While creating "ValueMeasure" getting error
The value for 'Page Views' cannot be determined. Either the column doesn't exist, or there is no current row for this column.
Following is measure which I created


ValueMeasure = SWITCH(SELECTEDVALUE(Parameter[Parameter Order]), 0, [Page Views], 1 , [Clicks])

[Page Views] and [Clicks] are correct from Parameter table.



Screenshot 2024-07-24 at 5.20.45 PM.png

Page views and click are measures correct? 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix yes they are measures

Sorry for the question but you are creating a measure correct not a table? 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix , Yes I have created a measure which is "ValueMeasure"
I have created same as how you have shown. Something must be missing at my end.
Is it possible to share your pbix file to cross verify?

Attaching images for clarifications

Screenshot 2024-07-25 at 10.01.16 AM.png

Screenshot 2024-07-25 at 10.10.13 AM.png 
Screenshot 2024-07-25 at 10.28.40 AM.png

Hi @rahul-opp ,

 

Your problem is that this are column on your model and not measures.

 

Change the Values measure to:

ValueMeasure =
SWITCH (SELECTEDVALUE(Parameter[Paramete Order]),
0, SUM('Master ASIN Join'[Page View]),
1, SUM('Master ASIN Join'[Clicks]))

Should work.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thanks @MFelix  🙌 It worked. It's good learning.
Further I will try to add addtional stuff like dropdown filter with daily, weekly, quarterly.

Will add another reply to this thread with detailed settings. 
I have created a sample pbix file but there is no option to upload it.

This dummy data
Screenshot 2024-07-26 at 12.22.50 PM.png

Create parameter as suggested.
Screenshot 2024-07-26 at 12.25.45 PM.png

Create Measure as suggested. In my case fields, Page Views and Clicks were from model ( not measures ), so used @MFelix 's last suggestion of measure creation.
Screenshot 2024-07-26 at 12.35.33 PM.png
After adding parameter to "Columns", click on dropdown arrow of Parameter added in Columns
and select "Show selected field" and then click on drill down arrow.
Screenshot 2024-07-26 at 12.45.05 PM.png

Screenshot 2024-07-26 at 12.54.19 PM.png

Don't forget to accept as solution answer so that it can help others


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Also found similar questions which uses Unpivot approach, which I also tried , but didn't worked for me. Also Unpivoting existing columns which I want to use in Matrix, will creatre issue as same dataset, I am or I will use in other reports where this unpivoting might not be needed.

Your approach looks good as it only do changes on DAX and visual level. 

https://community.fabric.microsoft.com/t5/Desktop/Swap-Matrix-visualization-Columns-Values/m-p/14099... 
https://community.fabric.microsoft.com/t5/Desktop/Matrix-Change-quot-Level-quot-of-columns-amp-value... 

MFelix
Super User
Super User

Hi @rahul-opp ,

 

Create a parameter field with the two measures you need then on the columns add the parameter and then the date this will allow to show the values on that hierarchy level.

 

https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix Thanks for reply. I will check the parameter part and update here

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.