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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sing_ideas
Regular Visitor

Cross Table to Flat Table

Hi,

 

Is it a must to flatten the cross table to a flat table using the "Unpivot Table" option in Query Editor of Power BI Desktop?

 

If I do so will the table which I linked from the Excel File in One Drive (for Business) will get updated whenever the input data are changed in the Excel file which then changes the values of the cross table. This cross table is linked to Power BI Desktop and then flattened.

 

Note : what I do in Excel?

 

Table 1 has got the input values and Table 2 got the formulas where the calculated values generated. This Table 2 is a cross table, which I convert it to Flat Table.

 

regards

Singaravelu S, CFP

1 ACCEPTED SOLUTION

Hi @sing_ideas,

 

Based on my test, the "Unpivot Table" option is the easiest and most appropriate solution to flatten a table. When you make any change to Excel File stored in One Drive, including changing data records (edit data values) or changing table structure (add or delete columns), the flat table will be updated automatically.

 

Alternatively, if you can also achieve the flat table via DAX:

Table =
UNION (
    SELECTCOLUMNS (
        'CrossTable',
        "Date", 'CrossTable'[Date],
        "Type", "Food",
        "Amount", 'CrossTable'[Food]
    ),
    SELECTCOLUMNS (
        'CrossTable',
        "Date", 'CrossTable'[Date],
        "Type", "Shelter",
        "Amount", 'CrossTable'[Shelter]
    ),
    SELECTCOLUMNS (
        'CrossTable',
        "Date", 'CrossTable'[Date],
        "Type", "Clothing",
        "Amount", 'CrossTable'[Clothing]
    )
)

But this new calculated table cannot get the update if you add or delete columns in source file.

 

Regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Very diffucult to tell from your descriptoin of the issue. Can you provide an example of your data and desired result?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi,

Below are 3 images, CrossTable, Flat Table, Query Editor.

 

CrossTableCrossTableFlatTableFlatTableQueryEditorUnpivotQueryEditorUnpivot

 

Hope, I am able to brief it clear with the screen shots.

 

External resources -

https://www.youtube.com/watch?v=pUXJLzqlEPk

http://nhsexcel.com/excel-pivot-table-crosstab-flat-list/

regards,

Singaravelu S

Hi @sing_ideas,

 

Based on my test, the "Unpivot Table" option is the easiest and most appropriate solution to flatten a table. When you make any change to Excel File stored in One Drive, including changing data records (edit data values) or changing table structure (add or delete columns), the flat table will be updated automatically.

 

Alternatively, if you can also achieve the flat table via DAX:

Table =
UNION (
    SELECTCOLUMNS (
        'CrossTable',
        "Date", 'CrossTable'[Date],
        "Type", "Food",
        "Amount", 'CrossTable'[Food]
    ),
    SELECTCOLUMNS (
        'CrossTable',
        "Date", 'CrossTable'[Date],
        "Type", "Shelter",
        "Amount", 'CrossTable'[Shelter]
    ),
    SELECTCOLUMNS (
        'CrossTable',
        "Date", 'CrossTable'[Date],
        "Type", "Clothing",
        "Amount", 'CrossTable'[Clothing]
    )
)

But this new calculated table cannot get the update if you add or delete columns in source file.

 

Regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yulgu-msft

 

Thanks for your clarification.

 

The same Unpivot Table option is available in Excel 2016, but it creates a new table and fills it with the values without any link to the source. Power BI is really great in making sure to have a Cross Table in Exce 2016 which is easier to do claculations and unpivot the same table in Power BI with link to the source table.

 

I am really glad to get a confirmation from an expert like you and thanks to the Power BI Product team.

 

regards,

Singaravelu S, CFP

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.