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
mitchpowell
Regular Visitor

SELECTCOLUMNS in calculated table - column order wrong

I have a strange issue. Using SELECTCOLUMNS to create a calculated table. One of the fields ALWAYS shows up as the LAST field in the resulting table REGARDLESS of where I place it in the SELECTCOLUMNS. 

 

What am I missing??

4 REPLIES 4
v-zhangti
Community Support
Community Support

Hi, @mitchpowell 

 

Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures or Excel. I look forward to your response.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is a calculated table. Code and screen shot of results below. Lot of code but the relevent part is that the end where the "Ext Price" is fourth from last but shows up as last column in results. 

 

Distribution Export =

VAR FilterTable =
    SELECTCOLUMNS (
        FILTER ( Invoice, [Invoice vs Distr Amt] = 0 ),
        "Key", Invoice[Key]
    )
VAR ReturnTable =
    SELECTCOLUMNS (
        //        CALCULATETABLE ( Distribution, FilterTable ),
        CALCULATETABLE (
            Distribution,
            FilterTable,
            FILTER ( Distribution, Distribution[Debit Entity] <> "" ),
            'Conversion entities'
        ),
        "Branch", Distribution[Debit Entity],
        "Type", If(Distribution[Amount]<0,"Credit Memo", "Invoice"),
        "Invoice", RELATED ( Invoice[Invoice] ),
        "Document Date",
            IF (
                RELATED ( Invoice[Status_Date] ) < DATE ( 2016, 1, 1 ),
                DATE ( 2016, 1, 1 ),
                RELATED ( Invoice[Status_Date] )
            ),
        "Post Period",
            FORMAT (
                IF (
                    RELATED ( Invoice[Status_Date] ) < DATE ( 2016, 1, 1 ),
                    DATE ( 2016, 1, 1 ),
                    RELATED ( Invoice[Status_Date] )
                ),
                "MM-YYYY"
            ),
        "Customer ID", RELATED ( Invoice[F_Customer] ),
        "Location", "MAIN",
        "Terms", "30D",
        "AR Account", Distribution[Debit Account],
        "AR Subaccount", Distribution[Debit Subaccount],
        "Project", Distribution[Job],
        "Balance", Distribution[Amount],
        "Amount", Distribution[Amount],
        "Line Branch", Distribution[Debit Entity],
        "Ext Price", Distribution[Amount],
        "Account", Distribution[Debit Account],
        "Subaccount", Distribution[Credit Subaccount],
        "temp_Folder", Distribution[Folder]
    )
RETURN
    ReturnTable

 

mitchpowell_0-1699967473517.png

 

mitchpowell
Regular Visitor

There's a reason I'm doing this in desktop and not PQ so my question stands...

Ahmedx
Super User
Super User

you should do this in power query there you need to add an index column to keep order

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!

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.

Top Solution Authors