Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Create 3 rows for every record

i have recods in excel like

 

company region market        rev1India revgermany   revsingapore

EAC Sols  APAC   Germany    44682       -                   12455

 

Now i want in power bi to look like

Company  Region  Market       Country        Rev

EAC sols    APAC    Germany    India             44682

EAC sols    APAC    Germany    Germany        -

EAC sols    APAC    Germaby    Singapore     12455

 

So basically i need 2 things

create rows 3 rows for every record for india,germany and singapore and then put the revenue values against it,

 

Help!! 

 

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @Anonymous ,

 

On the query editor select the 3 columns of Rev and then choose unpivot. You will then get 2 column attribute and value.

 

You then just have to rename the columns and on the attribute column make a replace rev by nothing and you you get the information needed.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnV0VgjOzylW0lFyDHB0BlLuqUW5iXmVQJaJiZmFEZA2AGJDIxNTU6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Company = _t, Region = _t, Market = _t, revIndia = _t, Revgermany = _t, revsingapore = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Company", type text}, {"Region", type text}, {"Market", type text}, {"revIndia", Int64.Type}, {"Revgermany", Int64.Type}, {"revsingapore", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Company", "Region", "Market"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Country"}}),
    #"Replaced Value" = Table.ReplaceValue(#"Renamed Columns","rev","",Replacer.ReplaceText,{"Country"})
in
    #"Replaced Value"

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

If you want to implement it with DAX, you could try this:

 

Create a new table:

Table 1 =
UNION (
    SELECTCOLUMNS (
        'Table',
        "Company", 'Table'[Company],
        "Region", 'Table'[Region],
        "Market", 'Table'[Market],
        "Country", "India",
        "Rev", 'Table'[revIndia]
    ),
    SELECTCOLUMNS (
        'Table',
        "Company", 'Table'[Company],
        "Region", 'Table'[Region],
        "Market", 'Table'[Market],
        "Country", "Germany",
        "Rev", 'Table'[Revgermany]
    ),
    SELECTCOLUMNS (
        'Table',
        "Company", 'Table'[Company],
        "Region", 'Table'[Region],
        "Market", 'Table'[Market],
        "Country", "Singapore",
        "Rev", 'Table'[revsingapore]
    )
)

 

v-xuding-msft_0-1599037185839.png

 

 

Best Regards,
Xue Ding
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

4 REPLIES 4
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

If you want to implement it with DAX, you could try this:

 

Create a new table:

Table 1 =
UNION (
    SELECTCOLUMNS (
        'Table',
        "Company", 'Table'[Company],
        "Region", 'Table'[Region],
        "Market", 'Table'[Market],
        "Country", "India",
        "Rev", 'Table'[revIndia]
    ),
    SELECTCOLUMNS (
        'Table',
        "Company", 'Table'[Company],
        "Region", 'Table'[Region],
        "Market", 'Table'[Market],
        "Country", "Germany",
        "Rev", 'Table'[Revgermany]
    ),
    SELECTCOLUMNS (
        'Table',
        "Company", 'Table'[Company],
        "Region", 'Table'[Region],
        "Market", 'Table'[Market],
        "Country", "Singapore",
        "Rev", 'Table'[revsingapore]
    )
)

 

v-xuding-msft_0-1599037185839.png

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , select the last three columns and unpivot

https://radacad.com/pivot-and-unpivot-with-power-bi
Transpose : https://yodalearning.com/tutorials/power-query-helps-transposing-data/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
MFelix
Super User
Super User

Hi @Anonymous ,

 

On the query editor select the 3 columns of Rev and then choose unpivot. You will then get 2 column attribute and value.

 

You then just have to rename the columns and on the attribute column make a replace rev by nothing and you you get the information needed.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnV0VgjOzylW0lFyDHB0BlLuqUW5iXmVQJaJiZmFEZA2AGJDIxNTU6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Company = _t, Region = _t, Market = _t, revIndia = _t, Revgermany = _t, revsingapore = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Company", type text}, {"Region", type text}, {"Market", type text}, {"revIndia", Int64.Type}, {"Revgermany", Int64.Type}, {"revsingapore", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Company", "Region", "Market"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Country"}}),
    #"Replaced Value" = Table.ReplaceValue(#"Renamed Columns","rev","",Replacer.ReplaceText,{"Country"})
in
    #"Replaced Value"

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Greg_Deckler
Community Champion
Community Champion

@Anonymous - Select your last three columns in Power Query editor and then right-click in the column header area and select Unpivot.

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors