Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hi, I'm have a table which has been setup as follows:
| PostCode | CompanyA | CompanyB | CompanyC | CompanyD |
| 3015 | Yes | Yes | No | No |
| 3016 | No | Yes | No | Yes |
| 3017 | No | Yes | Yes | Yes |
| 3018 | No | No | Yes | Yes |
This unfortunately has company names as column headers and whether they operate or not in a particular postcode in thier own column.
To be able to work with it effectively, I want to transform it to the following where I loop through each row and column and add a row in the new table for each time a "Yes" is found, and then put the Company Name which is in the header and the postcode from the first column as the values.
| Company | PostCode |
| CompanyA | 3015 |
| CompanyB | 3015 |
| CompanyB | 3016 |
| CompanyD | 3016 |
| CompanyB | 3017 |
| CompanyC | 3017 |
| CompanyD | 3017 |
| CompanyC | 3018 |
| CompanyD | 3018 |
Is this possible? I'm having trouble understanding how to use loop type functions using M Query or Dax or anything in PowerBi.
Thanks for any advice people can provide.
Solved! Go to Solution.
hi, @jz7ssr
You can use Unpovit Function in Edit Queries and then filter Value is Yes as below:
Step1:
Select Column CompanyA, CompanyB, CompanyC, CompanyD then click Unpovit Columns
Step2:
Filter the Value is "Yes"
Result:
Best Regards,
Lin
hi, @jz7ssr
You can use Unpovit Function in Edit Queries and then filter Value is Yes as below:
Step1:
Select Column CompanyA, CompanyB, CompanyC, CompanyD then click Unpovit Columns
Step2:
Filter the Value is "Yes"
Result:
Best Regards,
Lin
Hi,
You un-pivot in the edit query window.
Go to the section "Unpivot; Turning Columns to Rows; Name, Values" in below link you will find the step by step process
http://radacad.com/pivot-and-unpivot-with-power-bi
Thankyou! This does it all in one click, I was trying to write a complicated looping routine.
Perfect thanks.
Yes, in Power Query, select your PostalCode column, right-click in select Unpivot other columns.
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 29 | |
| 27 | |
| 25 | |
| 25 | |
| 18 |
| User | Count |
|---|---|
| 54 | |
| 49 | |
| 43 | |
| 36 | |
| 32 |