cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Resolver I

## How to Sort Sub Header in Switch Case in DAX

I have to sort the sub header columns

values =
var ABC_MTD
var ABC_YTD
var XYZ_MTD
var XYZ_YTD
RETURN
SWITCH(
"MTD", ABC_MTD,
"YTD", ABC_YTD,
"MTD", XYZ_MTD,
"YTD", XYZ_YTD)

Above we are able to create the measure but while pulling this values MTD and YTD values are not correct because it has same value for bpth columns.

how to sort or differentiate here without changing the column names. As it should be MTD and YTD for both columns.
1 ACCEPTED SOLUTION
Resolver I

I have found the solution for this topic.

In above case we have sub headers are repeating as MTD and YTD for 8 columns.

What we did was in switch function we have used space for MTD and YTD so that each and every sub ehader will be unique

Ex: 1. "MTD", "YTD"

2. " MTD", " YTD"

3. "  MTD", "  YTD"

We have given extra space so that dax considers each sub header as unique and sort accordingly.

2 REPLIES 2
Resolver I

I have found the solution for this topic.

In above case we have sub headers are repeating as MTD and YTD for 8 columns.

What we did was in switch function we have used space for MTD and YTD so that each and every sub ehader will be unique

Ex: 1. "MTD", "YTD"

2. " MTD", " YTD"

3. "  MTD", "  YTD"

We have given extra space so that dax considers each sub header as unique and sort accordingly.

Super User

@Optimusprime_25 , The information you have provided is not making the problem clear to me. Can you please explain with an example?

refer if my blog on a similar topic can help

https://medium.com/chandakamit/power-bi-when-i-felt-lazy-and-i-needed-too-many-measures-ed8de20d9f79

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors