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
Anonymous
Not applicable

Order columns with DAX

Good morning,

please l'm using the the DAX function SELECTCOLUMNS to keep two columns from a table. But the problem is that, but the two columns are given in the result in an order that does not suit me. I don't know how to put my two columns in the right order.

Thanks for your help.

 

Please see below the DAX query used:

TABAbsent1monthJan22InnerJoin = SELECTCOLUMNS( NATURALINNERJOIN(
VAR Tab_TransdateLastMonth= CALCULATETABLE(VS, MONTH(VS[TransDate])=1 && YEAR(VS[TransDate])=2022 && VS[IsDeleted]= "false" && VS[PatientStatus]="Defaulter")
RETURN
SUMMARIZE(Tab_TransdateLastMonth
,VS[BaselineCode], "LastRDVDateCurrent", MAX(VS[TransDate])),
 
VAR Tab_TransdateLastMonth= CALCULATETABLE(VS, MONTH(VS[TransDate])=12 && YEAR(VS[TransDate])=2021 && VS[IsDeleted]= "false" && (VS[PatientStatus]="On Tx"|| VS[PatientStatus]="Transfered In" || VS[PatientStatus]="Restarted Tx"))
RETURN
SUMMARIZE(Tab_TransdateLastMonth
,VS[BaselineCode], "LastRDVDatePrevious", MAX(VS[TransDate]))
), "BaselineCode", [BaselineCode], "LastRDVDateCurrent", [LastRDVDateCurrent])
 
The order of the columns in the result is: LastRDVDateCurrent; BaselineCode
But will like to have : BaselineCode; LastRDVDateCurrent
3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Looking at the summarize in the DAX code Return, BaselineCode should be first. Unless there is something else used.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks! It should be first but it isn't 😒

Anonymous
Not applicable

Hi @Anonymous,

In fact, the power bi data model tables do not include any row and column index. So the current table column orders are pre-rendered by the power bi data model and they may be changed if any update or change at the backend data loading.
Did you do any changes to your formula? The generated data table structure will be fixed and they not update when you do some small changes. (e.g. change two columns order)

For this scenario, you can backup your formula and manually do some big changes to force update the table structure. 

For example:

change table formula to blank and apply the change, then paste raw DAX formula to force re-active to update table structure.

TABAbsent1monthJan22InnerJoin = {0}

Regards,

Xiaoxin Sheng

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.