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
klyjen
New Member

Create table/report with each row and one column value

Hi -- I am a PowerBI newbie so thanks in advance for any assistance!

 

I have a data source organized like this:

CodeValueAValueBValueCValueD...ValueAX
Code010320 
Code024306 
Code030040 
Code042548 

 

I am trying to manipulate the data to get something that only shows the Value column(s) where the values aren't zero. I can envision it like this:

 

Code 01

ValueB - 3

Value C - 2

Code 02

ValueA - 4

Value B - 3

ValueD - 6

Code03

ValueC - 4

Code04

ValueA - 2

ValueB - 5

ValueC - 4

ValueD - 8

 

or even like this:

CodeValueLabelValueValue
Code01ValueB

3

Code01ValueC

2

Code02ValueA

4

Code02ValueB3
Code02ValueD

6

Code03ValueC4
Code04ValueA2
Code04ValueB5
Code04ValueC4
Code04ValueD8

 

Note that there are about 35 'value' columns currently, but this will grow/shrink in other instances of this data. I'd love something that allows me to run this against the data regardless of the number of columns.

 

I keep picturing it as a query to populate a new table, like

For Each [Code.row],

For Each [Value.column]

If Value.Column>0,

Create row (Code.row, Value.Column, Value)

Next

Next

 

(I'm not a coder, but that is the logic I want to use so that the # of columns and # of rows can be variable.)

 

Is this even possible? Any suggestions would be appreciated. Thanks in advance!

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

This is much easier in Power Query than you might expect. All you need to do is unpivot the Value columns and filter out the zeros.

 

See also: https://www.howtoexcel.org/power-query/how-to-unpivot-data-with-power-query/

View solution in original post

2 REPLIES 2
klyjen
New Member

Wow. This was exactly what I needed. Thank you so much!

AlexisOlson
Super User
Super User

This is much easier in Power Query than you might expect. All you need to do is unpivot the Value columns and filter out the zeros.

 

See also: https://www.howtoexcel.org/power-query/how-to-unpivot-data-with-power-query/

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.