Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Transposing Data

Hi All, 

 

I have seen other posts regarding transposing rows and columns, but none that match my specific circumstance. The current structure of my data table is as such:

Column 1Column 2Column 3Column 4Column 5Column 6
nullRETAILER IDA111A222A333A444
nullPROD. CODE0123123423453456
nullDESCRIPTIONABCBCDCDEDEF
BELGIUMJan 20230184
BELGIUMFeb 20231415
FRANCEJan 2023261720


I need to make the transpositions to achieve a format like this:

CountryDateRetailer IDProd. CodeDescriptionValue
BELGIUMJAN 2023A1110123ABC0
BELGIUMFEB 2023A1110123ABC1
FRANCEJAN 2023A1110123ABC2

 

And so on. 

Any help would be greatly appreciated. 

11 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Not quite. The next step would be to unpivot Column 3 thru Column 6 in Table 3 of your file. However, it does not produce the desired result as Prod Code 0123 should have monthly sales of 0, 1, and 2. 

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        Anonymous So what would the final result look like fully from the example given?

  • Brunner_BI's avatar
    Brunner_BI
    Impactful Individual

    I guess it depends on if you really ONLY have 3 rows with Column 1 as NULL or it is more than that, but you can do the following.

    Create a second query referencing the old query, taking only the part of the table that has Column 1 as null and transposing that.

    Then do various transformations in the first query

    As a last step, create a new query "append as new query" and append the two tables, make sure here that your column names match (you can adjust them manually)

     

    Maybe this gives you what you need to figure it out.

    My point is that the structure of your rows are so inherently different that i would separate them completely, transform it so it will fit together somehow and then as a last step actually append them (put them back together)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you. Yes, those 3 null values are the only ones in thet column. I think this is similar to what Greg_Deckler proposed (which is getting me closer but not completely to the solution). 

      Further, what I shared is a transformation of an original raw data source in an even more unworkable format.