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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.