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

Formatting a visual for export as a matrix

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.

Fourthsky_0-1661809589908.png

 

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 2200911   1 
18 7/30/2022 2200911   1 
18 7/31/2022 2200911   1 
18 8/1/2022 2200912   1 
18 8/2/2022 2200911   1 
18 8/3/2022 2200911   1 
18 8/7/2022 2200911   1 
25 8/7/2022 22008511500101
30 7/25/2022 220082150 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
18hours7/29/2022 2200911
18Sub7/29/2022 2200911
18hours7/30/2022 2200911
18Sub7/30/2022 2200911
18hours7/31/2022 2200911
18Sub7/31/2022 2200911
Shortened for brevity…    
25hours8/7/2022 2200851
25Kms Reg8/7/2022 220085150
25Truck8/7/2022 2200851
25Camp8/7/2022 2200851
30hours7/25/2022 2200821
30Kms Reg7/25/2022 22008250
30Truck7/25/2022 2200821
30Camp7/25/2022 2200821

 

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.

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

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):

vyadongfmsft_0-1662024043837.png

 

You will get a table like this:

vyadongfmsft_1-1662024316893.png

 

Create a table visual and then export data:

vyadongfmsft_2-1662024471188.png

 

The exported data in csv is shown like below:

vyadongfmsft_3-1662024563350.png

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.

View solution in original post

2 REPLIES 2
v-yadongf-msft
Community Support
Community Support

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):

vyadongfmsft_0-1662024043837.png

 

You will get a table like this:

vyadongfmsft_1-1662024316893.png

 

Create a table visual and then export data:

vyadongfmsft_2-1662024471188.png

 

The exported data in csv is shown like below:

vyadongfmsft_3-1662024563350.png

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.

mahoneypat
Employee
Employee

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

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.