Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
I have an issue where my data tables are relating properly, but I can not quite shape my visuals in the correct way to get my CSV data export.
Here is an example of my current Visual.
Simplified without irrelevant blank columns in CSV the export looks like this:
employee_number | earning_code | Date | Job Code | hours | Kms_Reg | Kms_Tow | Truck | Sub | Camp |
18 | 7/29/2022 | 220091 | 1 | 1 | |||||
18 | 7/30/2022 | 220091 | 1 | 1 | |||||
18 | 7/31/2022 | 220091 | 1 | 1 | |||||
18 | 8/1/2022 | 220091 | 2 | 1 | |||||
18 | 8/2/2022 | 220091 | 1 | 1 | |||||
18 | 8/3/2022 | 220091 | 1 | 1 | |||||
18 | 8/7/2022 | 220091 | 1 | 1 | |||||
25 | 8/7/2022 | 220085 | 1 | 150 | 0 | 1 | 0 | 1 | |
30 | 7/25/2022 | 220082 | 1 | 50 | 1 | 1 |
I need columns 5-10 to not be columns, but rather new rows with the column heading as an entry under earning_code and associated with the correct emp number, date, and job code like this:
employee_number | earning_code | Date | Job Code | hours |
18 | hours | 7/29/2022 | 220091 | 1 |
18 | Sub | 7/29/2022 | 220091 | 1 |
18 | hours | 7/30/2022 | 220091 | 1 |
18 | Sub | 7/30/2022 | 220091 | 1 |
18 | hours | 7/31/2022 | 220091 | 1 |
18 | Sub | 7/31/2022 | 220091 | 1 |
Shortened for brevity… | ||||
25 | hours | 8/7/2022 | 220085 | 1 |
25 | Kms Reg | 8/7/2022 | 220085 | 150 |
25 | Truck | 8/7/2022 | 220085 | 1 |
25 | Camp | 8/7/2022 | 220085 | 1 |
30 | hours | 7/25/2022 | 220082 | 1 |
30 | Kms Reg | 7/25/2022 | 220082 | 50 |
30 | Truck | 7/25/2022 | 220082 | 1 |
30 | Camp | 7/25/2022 | 220082 | 1 |
I tried to do this in a Matrix and can conceptually get the correct format, but when it is exported to CSV the rows all become columns again. I need them to be formatted as rows above as they are to be imported into a different payroll program and this format is a requirement.
I'm wondering if this has to be a DAX script or a Power M query to be done properly? Any ideas are welcome.
Solved! Go to Solution.
Hi @Fourthsky ,
Maybe you need to implement your requirement in Power Query.
Please unpivot columns in Power Query like shown below(remove blank column [earing_code] first):
You will get a table like this:
Create a table visual and then export data:
The exported data in csv is shown like below:
Best regards,
Yadong Fang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Fourthsky ,
Maybe you need to implement your requirement in Power Query.
Please unpivot columns in Power Query like shown below(remove blank column [earing_code] first):
You will get a table like this:
Create a table visual and then export data:
The exported data in csv is shown like below:
Best regards,
Yadong Fang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
When you publish your report to the Power BI Service, you should now see the "Data with current layout" option when you export.
New Export to Excel Format in Power BI - Excelerator BI
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.