Forum Discussion

PowerBITestingG's avatar
PowerBITestingG
Icon for Resolver I rankResolver I
3 years ago

Row that should be a column

I have the following data:

 

CountryCustomer
USAApple
Days of supply30

 

The problem is that Days of Supply should be a column

 

CountryCustomerDays of Supply
USAApple30

 

So far I am not able to do it with Power Query

 

Any ideas?

2 Replies

  • I don't think that can be fixed in Power Query. You will need to fix it in at the source.

  • mahenkj2's avatar
    mahenkj2
    Icon for Solution Sage rankSolution Sage

    Hi PowerBITestingG ,

     

    It depends on what additional columns you may have and remaining data of these 2 columns. Incase you have a key column (Primary or ID column), then below can possibly be done:

     

    1. Connect main table in PQ.

    2. Duplicate it.

    3. Filter main table for not having 'Days of supply'

    4. Filer second table for having 'Days of supply'.

    5. Unpivot second table for Country and customer columns and then promote first row as header

    6. Now second table have ID column as well as 'Days of supply' column.

    7. Now relate or merge both tables with ID column

     

    The above is a possible approach. I could test on sample data you provided, but dont share here PQ code, reason much may depend on remaining data of your table. 

     

    Hope it helps!