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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
ninja18
Helper I
Helper I

Flip columns values (strings - dimensions/rows (Rows section in matrix)) based on parameter

I want to flip the column values based on parameter selection. For example I have two columns First Name and Last Name.

 

Parameter Values -->

First, Last

Last, First

 

First, Last Option:

First Name || Last Name

 

Last, First Option:

Last Name || First Name

1 ACCEPTED SOLUTION

Add extra rows to your field paramter table and another column to group the rows into

NamesParameter = 
{
    ( "FirstName", NAMEOF ( 'Names'[FirstName] ), 0, "First, Last" ),
    ( "LastName", NAMEOF ( 'Names'[LastName] ), 1, "First, Last" ),
    ( "FirstName", NAMEOF ( 'Names'[FirstName] ), 3, "Last, First" ),
    ( "LastName", NAMEOF ( 'Names'[LastName] ), 2, "Last, First" )
}

The order column determines their display order. 

danextian_0-1765685671644.gif

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

15 REPLIES 15
Shubham_rai955
Super User
Super User

Use a field parameter (or a simple DAX column if you only need a concatenated full name).

Option 1 – concatenated column (easiest)

Create a column in your dimension table:

Full Name := VAR FirstLast = 'DimPeople'[First Name] & " " & 'DimPeople'[Last Name] VAR LastFirst = 'DimPeople'[Last Name] & " " & 'DimPeople'[First Name] RETURN SWITCH ( SELECTEDVALUE ( 'Name Order Parm'[Order] ), "First, Last", FirstLast, "Last, First", LastFirst, FirstLast )

Name Order Parm is a disconnected table with values "First, Last" and "Last, First" used as a slicer.
Use Full Name on Rows of your matrix; changing the slicer flips the order.

Option 2 – field parameter for separate columns

If you truly need two separate columns, create a field parameter containing [First Name] and [Last Name], then duplicate it and use techniques for dynamic hierarchies so the parameter’s order depends on a small “Order” table controlled by a slicer.

Hi @Shubham_rai955 ,

Your suggestion is on the right track, and the key point is choosing the simplest solution that actually fits the requirement.

Let me clarify and slightly refine it.

Option 1 – Concatenated column (recommended in most cases)

If the requirement is only about display order (First Last vs Last First), then a single concatenated column is absolutely the best and cleanest solution.

However, one important correction:

A calculated column cannot react to a slicer.

So this logic should be implemented as a measure, not a column.

Correct approach (measure)
Full Name :=
VAR FirstLast =
SELECTEDVALUE ( 'DimPeople'[First Name] ) & " " &
SELECTEDVALUE ( 'DimPeople'[Last Name] )
VAR LastFirst =
SELECTEDVALUE ( 'DimPeople'[Last Name] ) & " " &
SELECTEDVALUE ( 'DimPeople'[First Name] )
RETURN
SWITCH (
SELECTEDVALUE ( 'Name Order Parm'[Order], "First, Last" ),
"First, Last", FirstLast,
"Last, First", LastFirst
)


Name Order Parm is a disconnected table used as a slicer

Use Full Name (measure) in a table or matrix

Changing the slicer flips the display order instantly

✔ Simple
✔ Performant
✔ Easy to maintain

⚠ Option 2 – Field parameter (only if you truly need separate columns)

If you genuinely need:

First Name and Last Name as separate fields

And want to change their order dynamically

Then a Field Parameter can work — but it is more complex and harder to maintain.

This approach:

Requires duplicating the parameter

Needs a helper “Order” table

Uses dynamic hierarchy tricks

It’s valid, but overkill unless you really need column-level control.

🧠 Recommendation

99% of cases → use Option 1 (measure-based concatenated name)

Only use field parameters if the business explicitly requires:

separate columns

dynamic reordering of those columns

Conceptual illustration
Slicer: Name Order
[ First, Last ] [ Last, First ]

Matrix:
┌───────────────────────┐
│ John Smith │ ← First, Last
│ Smith John │ ← Last, First
└───────────────────────┘


Thanks for sharing the idea — it’s a good one 👍
If this clarification helps, please consider giving a kudos
And if it answers the question fully, feel free to mark it as the Accepted Answer ✔

@SavioFerraz 

I took sample data as first name and last name. Actual data is different, so I would need two columns, rather than concatenated one. If you can eloborate Shubham's option 2 that would be great.

Hi @ninja18,

Thanks for the clarification — that helps a lot 👍
If you truly need two separate columns (not a concatenated display), then Shubham’s Option 2 using Field Parameters is the correct direction. Let me walk through it in a practical way.

Goal recap

You want:

Two separate columns (e.g. First Name and Last Name)

The order of those columns to change based on a slicer:

First Name | Last Name

Last Name | First Name

This cannot be done with a calculated column or a simple measure alone — Field Parameters are required.

Step 1 – Create the Name Order slicer table (disconnected)

Create a small table:

Name Order =
DATATABLE (
"Order", STRING,
{
{ "First, Last" },
{ "Last, First" }
}
)


Use this table as a slicer.

Step 2 – Create TWO field parameters
Parameter 1 – First Name

Create a field parameter containing only:

DimPeople[First Name]

Parameter 2 – Last Name

Create another field parameter containing only:

DimPeople[Last Name]

Power BI will generate tables similar to:

FirstName_Param
LastName_Param

Step 3 – Create a dynamic column order measure

Now create a helper measure to control visibility/order:

Show First Name :=
IF (
SELECTEDVALUE ( 'Name Order'[Order] ) = "First, Last",
1,
2
)

Show Last Name :=
IF (
SELECTEDVALUE ( 'Name Order'[Order] ) = "Last, First",
1,
2
)

Step 4 – Build the matrix visual

Add both field parameters to the Columns area

Sort the parameters by the corresponding measure:

First Name parameter → Show First Name

Last Name parameter → Show Last Name

Use the Name Order slicer to control the order

Power BI will reorder the columns dynamically.

Result
First Name Last Name

or

Last Name First Name

based on slicer selection — without concatenation.

⚠ Important notes

This works only in tables/matrices

It adds some complexity to the model

Maintenance is higher than the concatenated approach

But it is the only supported way to dynamically reorder separate columns

Conceptual illustration
Slicer:
[ First, Last ] [ Last, First ]

Matrix:
┌───────────────┐
│ First Name | Last Name │
└───────────────┘

OR

┌───────────────┐
│ Last Name | First Name │
└───────────────┘


Thanks for the follow-up — this is a great use case for field parameters 👍
If this explanation helps, please consider giving it a kudos
And if it answers your question, feel free to mark it as the Accepted Answer ✔

Hi @SavioFerraz 

 

I have tried creating everything by following your instructions, but it is not working.

It feels like their replies are AI generated.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thank you, Shubham !

 

Can you eloborate the option 2 please?

danextian
Super User
Super User

Hi @ninja18 

Create two columns with those combinations and use field parameters to control the column to display. If this isn't what you're looking for, please provide more context to your use case.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

I believe we have to create two field parameters (one for each column). Any possibility to control these two field parameters with another parameter, rather than displaying two parameters on screen?

If you wanted to just show a combination of first and last or last and first, you would only need two columns for that and a single field parameter. Or  are you trying to display two different columns at the same time?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Yes, two different columns - Both columns has to be displayed same time on report

Add extra rows to your field paramter table and another column to group the rows into

NamesParameter = 
{
    ( "FirstName", NAMEOF ( 'Names'[FirstName] ), 0, "First, Last" ),
    ( "LastName", NAMEOF ( 'Names'[LastName] ), 1, "First, Last" ),
    ( "FirstName", NAMEOF ( 'Names'[FirstName] ), 3, "Last, First" ),
    ( "LastName", NAMEOF ( 'Names'[LastName] ), 2, "Last, First" )
}

The order column determines their display order. 

danextian_0-1765685671644.gif

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

This is exactly what I need. It works with tabular view in matrix visual drill up / down as well. I have tested it.

 

Honestly this is the best solution with one parameter. I thought I had to create two field parameter and create ordering table and all. This solution is super lightweight for this requirement. Great !

Thank you,

 

Just a question, these can be drill up and down along with other columns right?

You should be able to but the behaviour might not be what you expect. I  don't have any other sample data to test this on.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.