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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Zakaria_1980
Post Patron
Post Patron

unpivoit columns

 

Dears,

 

i've made some changes under power query in power Bi service, and i got the following outcome. what i noticed is that for some KPIs i don't have for the same row and for the same KPI, both status and comment, but for the same KPI i have one row for status and another one for comment

 

Capture.PNG

 

Below what I want to be displayed in power Bi, so i can work on my visuals. whenever the row related to status and comments is empty, that row should be deleted

Capture1.PNG

 

 

Thanks in advance.

1 ACCEPTED SOLUTION

Hi @Zakaria_1980 ,

You can add a step after 'Added Custom' step by this formula:

filter rows.png

= Table.SelectRows(#"Added Custom",each ([Value] = "Red" or [Value] = "Amber" or [Value] = "Green" or [Value] = "Yes"))

Then remove and rename columns to get the same result:

 new table.png

Here is the modified report, please refer the New Table in this report: unpivot columns.pbix

 

Best Regards,
Yingjie Li

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

8 REPLIES 8
amitchandak
Super User
Super User

@Zakaria_1980 , what was initial data?Can you share sample data and sample output in table format?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

how can i attach xls file for you? i don't know how to do it here please.

Thanks

 

Capture.PNG

 

please find above the input and the output i need to get

 

thanks in advance

 

any feedback please ?

 

Hi @Zakaria_1980 ,

You can achieve this in power query editor:

1. Select [Project Name] and [Week] column to use 'Unpivot other columns'

2. Spilit column by delimiter:

spilit column.png

3. Use this formula to add a custom column:

let z=[Attribute.1],p=[Attribute.2],
tab=
Table.Column(
Table.SelectRows(#"Changed Type1",each [Attribute.1]=z and [Attribute.2]=" Comments"
),
"Value"
)
in
if
List.Count(tab)>0 then
tab{0} else null

custom column.png

4. Choose row 9 and remove bottom 9 rows:

remove rows.png

5. Remove unnecessary columns and rename other columns to get the final result:

result.png

 

Attached my sample file that hopes to help you, please check and try it: Unpivot columns.pbix

 

Best Regards,
Yingjie Li

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

 

Thanks a lot, it seems all is fine, expect the removed bottom rows. what i've shared with you is just a sample on 1 project for 1 week but in my DB i have thousands of project, weeks... i cannot count how many rows to delete from bottom knowing that my DB is refreshed and each next week will be added in the DB.

 

maybe we can say whenever Value column= Red or Amber or Green or Yes ==> Keep that row else Delete that row

 

could you share with me the new PBI report to adapt it to my DB taking into account my above hint please ?

 

Thanks in advance.

 

 

Hi @Zakaria_1980 ,

You can add a step after 'Added Custom' step by this formula:

filter rows.png

= Table.SelectRows(#"Added Custom",each ([Value] = "Red" or [Value] = "Amber" or [Value] = "Green" or [Value] = "Yes"))

Then remove and rename columns to get the same result:

 new table.png

Here is the modified report, please refer the New Table in this report: unpivot columns.pbix

 

Best Regards,
Yingjie Li

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

vanessafvg
Super User
Super User

its a bit diffiult to know what you have done without seeing your code, also you say you did this in the power bi service? do you have any duplication happening?




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors