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
ez1138
Frequent Visitor

Listing Values, Columns Axis

Hi, I have a large number of columns in SQL Server (150) that have values.  Let's say the values are green, blue, red.  My goal is to display all of the columns with a value of green from top to bottom vs. a table that wants to add the columns left to right.

 

Is there a way to do this?

7 REPLIES 7
lbendlin
Super User
Super User

Columns don't have values. They have row numbers (or indexes) which then point to cells that have values.

 

To swap columns and rows you can use Pivot/unpivot transforms. 

 

You would  need to run a custom function that identifies the names of the columns containing cellse with the value "green".

 

Then you would do a SelectColumns against that list

 

Then you would do the pivoting thing to swap rows and columns.

 

Now the question is - how many rows does your table have?  This might be fine for 20 rows, but will certainly not work for millions of rows.

 

For your proposed solution, do you have any direction to perform/create the function?

provide some sample data and the expected result

Hi, here's the same information.  For my real data, I have hundreds title, description and "status" columns.

 

Audit_IDAudit_DateCompany_IDABC123_TitleABC123_DescriptionABC123_StatusXYZ123_TitleXYZ123_DescriptionXYZ123_Status
1

1/1/20

1ABC123_Title #1ABC123_Description #1ImplementedXYZ123_Title #1XYZ123_Description #1Not Implemented
22/1/202ABC123_Title #2ABC123_Description #2ImplementedXYZ123_Title #2XYZ123_Description #2Not Implemented
33/1/203ABC123_Title #3ABC123_Description #3ImplementedXYZ123_Title #3XYZ123_Description #3Not Implemented
44/1/204ABC123_Title #4ABC123_Description #4ImplementedXYZ123_Title #4XYZ123_Description #4Not Implemented
55/1/205ABC123_Title #5ABC123_Description #5ImplementedXYZ123_Title #5XYZ123_Description #5Not Implemented

 

Ideally I would like to have a report showing the following:

 

Company 1

Date Performed (1/1/20)

 

ImplementedABC123_Title

 

Not ImplementedXYZ123_Title
ez1138
Frequent Visitor

Sorry, tables smashed together and I didn't see a spot to upload an excel file.

Hi @ez1138 ,

 

I don't particularly understand what you want.

Do you want to convert Table 1 to get Table 2?

Table1

r9.PNG

Table2

r11.PNG

 

Best regards,
Lionel Chen

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

 

Thanks for the reply.  I have a few hundred columns and only a few hundred rows.  I have no clue, yet, on how to do what you mentioned although it moves the ball forward and I will research it.  Thanks!

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.