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

How do I keep my dates when I transpose a query?

Hello everyone,

 

I have a query that is connected to a Smartsheet file and I am having troubles while transposing my table. Originally, my KPIs are in rows (metrics below) and my month/year are column headers and I wish exactly the opposite: KPIs in columns and month/year in rows (see below).

 

1.png

When I transpose the table, the dates simply disappear! (see below)

2.png

How can I transpose witouth loosing the dates?

 

Thank you,

 

Barbara Braga

1 ACCEPTED SOLUTION
AkhilAshok
Solution Sage
Solution Sage

You can try the following steps:

 

1. Click on the Matric column and select Transform -> Unpivot Other columns

 

2. Click on Matric column again and select Transform -> Pivot Column, selecting Values column as Value

View solution in original post

7 REPLIES 7
AkhilAshok
Solution Sage
Solution Sage

You can try the following steps:

 

1. Click on the Matric column and select Transform -> Unpivot Other columns

 

2. Click on Matric column again and select Transform -> Pivot Column, selecting Values column as Value

Hi! Thanks...it almost worked.

Now my dates are in a single column and my KPIs are headers. However, the KPIs number appears now as 0 or 1, and these are not real number. How can I get the real numbers?

 

3.png

 

Can you check if the last part of the M-code in the formula bar in List.Sum?

 

= Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Metric]), "Metric", "Value", List.Sum)

I think it worked. While doing the second step (2. Click on Matric column again and select Transform -> Pivot Column, selecting Values column as Value) I went to advanced options and in Aggregate Value Function I selected "Don't aggregate"option.

The last M-code in the formula is: = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Metric]), "Metric", "Value")

 

It worked perfectly for the majority of the KPI (the actual number came out). However, for some of them the error message was displayed instead of the actual number that is inside the Smartsheet. Any clue why? Is this probably an error on the Smartsheet-PBI communication?

 

4.png

Can you check what the error says?

5.png

I think the error is happening probably because, you gave don't aggregate while pivoting. You could try "Sum" or "Max" instead of "Don't aggregate"

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.