Calculated column from Data Model order in Worksheet

%3CLINGO-SUB%20id%3D%22lingo-sub-1587069%22%20slang%3D%22en-US%22%3ECalculated%20column%20from%20Data%20Model%20order%20in%20Worksheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1587069%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20DAX%20column%20in%20the%20Data%20Model%20table%20which%20comes%20through%20to%20the%20Worksheet%20as%20the%20last%20column%20even%20though%20I%20have%20moved%20it%20in%20the%20Data%20Model%20view.%20I%20can%20move%20the%20column%20in%20the%20Worksheet%20but%20it%20goes%20back%20to%20the%20last%20position%20when%20I%20refresh%20the%20data.%20Can%20someone%20tell%20me%20what%20I'm%20doing%20wrong%20please%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1587069%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1587882%22%20slang%3D%22en-US%22%3ERe%3A%20Calculated%20column%20from%20Data%20Model%20order%20in%20Worksheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1587882%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F758674%22%20target%3D%22_blank%22%3E%40robinherrick%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20clarify%20bit%20more%20how%20do%20you%20add%20data%20to%20data%20model%20(add%20to%20data%20model%20table%2C%20Power%20View%20connector%2C%20Power%20Query)%3B%20adding%20the%20column%20do%20you%20add%20it%20only%20in%20Power%20Pivot%20or%20not%3B%20how%20do%20you%20return%20table%20from%20data%20model%20back%20to%20Excel%20sheet.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1590044%22%20slang%3D%22en-US%22%3ERe%3A%20Calculated%20column%20from%20Data%20Model%20order%20in%20Worksheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1590044%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EData%20is%20from%20Power%20Query%2C%20loaded%20to%20worksheet%20and%20data%20model.%3C%2FP%3E%3CP%3EEnter%20Data%20Model%20(in%20Power%20Pivot)%20to%20create%20DAX%20calculated%20column.%3C%2FP%3E%3CP%3EColumn%20appears%20in%20worksheet%20on%20Refresh.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20know%20any%20other%20way%20to%20get%20a%20table%20from%20the%20Data%20Model%20into%20a%20worksheet.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1590940%22%20slang%3D%22en-US%22%3ERe%3A%20Calculated%20column%20from%20Data%20Model%20order%20in%20Worksheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1590940%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F758674%22%20target%3D%22_blank%22%3E%40robinherrick%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20see%2C%20thank%20you.%3C%2FP%3E%0A%3CP%3EOkay%2C%20if%20we%20Power%20Query%20left%20table%2C%20load%20to%20data%20model%20and%20return%20to%20Excel%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20324px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F212624iF417E364F16A5973%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Eadding%20in%20the%20middle%20any%20calculated%20column%20in%20the%20middle%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20319px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F212625i4C384EEE55669177%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Efirst%20will%20be%20returned%20all%20query%20columns%20and%20after%20that%20additional%20ones.%20Moreover%2C%20Power%20Pivot%20keeps%20the%20same%20order%20if%20check%20tree%20view%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20124px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F212626iB5F82E2CC21BECA6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EI'd%20open%20Data-%26gt%3BExisting%20Connection%20and%20select%20any%20existing%20table%20at%20any%20place%2C%20but%20better%20not%20one%20returned%20by%20Power%20Query.%20That%20could%20be%20our%20source%20table%2C%20but%20I%20created%20this%20small%20Table2%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20393px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F212627i5D6C45E229ED61AD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EOpen%20and%20save%20result%20into%20Excel%20sheet.%20That%20will%20be%20duplication%20of%20our%20Table2%2C%20in%20background%20it%20will%20be%20added%20to%20data%20model%20as%20well.%3C%2FP%3E%0A%3CP%3ERight%20click%20on%20this%20table%2C%20from%20menu%20Table-%26gt%3BEdit%20DAX%2C%20from%20drop-down%20menu%20in%20appeared%20window%20select%20DAX%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20407px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F212628iDDB8BFB3542636E6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Eand%20instead%20of%20Table2%20enter%20DAX%20expression%20here%20as%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3Eevaluate%0Asummarize(%0ATable1%2C%0Atable1%5Ba%5D%2C%0Atable1%5Be%5D%2C%0Atable1%5Bb%5D%2C%0Atable1%5Bc%5D%0A)%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIn%20general%20that%20could%20be%20any%20proper%20dax%20query%20which%20we%20evaluate%20here.%20Result%20is%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20305px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F212629iAB67840120EC4965%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPerhaps%20in%20first%20case%20EVALUATE%20in%20background%20works%20as%20with%20ADDCOLUMNS%2C%20when%20there%20is%20no%20way%20to%20change%20order%20of%20added%20columns%2C%20but%20that's%20only%20the%20guess.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I have a DAX column in the Data Model table which comes through to the Worksheet as the last column even though I have moved it in the Data Model view. I can move the column in the Worksheet but it goes back to the last position when I refresh the data. Can someone tell me what I'm doing wrong please?

3 Replies
Highlighted

@robinherrick 

Could you please clarify bit more how do you add data to data model (add to data model table, Power View connector, Power Query); adding the column do you add it only in Power Pivot or not; how do you return table from data model back to Excel sheet.

Highlighted

@Sergei Baklan 

Data is from Power Query, loaded to worksheet and data model.

Enter Data Model (in Power Pivot) to create DAX calculated column.

Column appears in worksheet on Refresh.

 

I don't know any other way to get a table from the Data Model into a worksheet.

Highlighted

@robinherrick 

I see, thank you.

Okay, if we Power Query left table, load to data model and return to Excel

image.png

adding in the middle any calculated column in the middle

image.png

first will be returned all query columns and after that additional ones. Moreover, Power Pivot keeps the same order if check tree view

image.png

I'd open Data->Existing Connection and select any existing table at any place, but better not one returned by Power Query. That could be our source table, but I created this small Table2

image.png

Open and save result into Excel sheet. That will be duplication of our Table2, in background it will be added to data model as well.

Right click on this table, from menu Table->Edit DAX, from drop-down menu in appeared window select DAX

image.png

and instead of Table2 enter DAX expression here as

evaluate
summarize(
Table1,
table1[a],
table1[e],
table1[b],
table1[c]
)

In general that could be any proper dax query which we evaluate here. Result is

image.png

 

Perhaps in first case EVALUATE in background works as with ADDCOLUMNS, when there is no way to change order of added columns, but that's only the guess.