Forum Discussion

Fourthsky's avatar
Fourthsky
Frequent Visitor
4 years ago
Solved

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.

 

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.

  • 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.

2 Replies

  • v-yadongf-msft's avatar
    v-yadongf-msft
    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):

     

    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.