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
SJHALANI
Helper I
Helper I

Table Transformation

Hi Guys!


I have the below table in Power BI which has Last 5 days currency FX rates. 

SJHALANI_0-1687192125321.png


I want to Transform the above table to the format given below.

Currency6/16/20236/15/20236/15/20236/15/20236/15/2023
AED Currncy3.67293.6733.67293.67293.6729
ANG Currncy1.791.791.791.791.79


I am looking for steps to be used in Power BI to do the above transformation. Any help is appreciated, TIA! 

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @SJHALANI ,

 

Please try:

First Transpose your data:

vjianbolimsft_0-1688353284969.png

Then add an index column:

vjianbolimsft_1-1688353318723.png

Add custom column:

vjianbolimsft_2-1688353360991.png

Reorder and remove columns:

vjianbolimsft_3-1688353411178.png

Transpose and remove column:

vjianbolimsft_4-1688353458345.png

Transpose table and use first row as header:

vjianbolimsft_5-1688353501904.png

Rename the column 1:

vjianbolimsft_6-1688353529830.png

Here is the M code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnR1UXAuLcpLrlTSUYIgRz93JKFYnWgll8SSVCA7oELBNzMFoghVCKTIyMDIWNdM19AMKGysZ2ZuZAlRiSxuqGduiaLYFKrYGFWtKTa1JjgMNsGm2BiHYmNsio1wKDaCK44FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Added Index" = Table.AddIndexColumn(#"Transposed Table", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Currency", each let 
id = _[Index]
in 
if [Column2] = "Px Mid" 
then
Table.SelectRows(#"Added Index", each [Index] = id-1)[Column1]{0}
else null),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"Currency", "Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Index"}),
    #"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"Column1", "Column2", "Index"}),
    #"Transposed Table1" = Table.Transpose(#"Removed Columns"),
    #"Removed Columns1" = Table.RemoveColumns(#"Transposed Table1",{"Column3", "Column4"}),
    #"Transposed Table2" = Table.Transpose(#"Removed Columns1"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table2", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", type text}, {"2023-6-16", type number}, {"2023-6-15", type number}, {"2023-6-14", type number}, {"2023-6-13", type number}, {"2023-6-12", type number}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Column1", "Currency"}})
in
    #"Renamed Columns"

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

SJHALANI
Helper I
Helper I

Hi,
The above would be great if I had only 2 currency types. Problem is that I have around 100 currencies, so this will require me to create 100 such tables and append. 

Kishore_KVN
Super User
Super User

Hello @SJHALANI ,

Please follow below steps to achieve it:

1. You have to duplicate the table remove blank columns and other columns by keeping only two columns for each currency type in one table. 

2. Use first row as headers two time to get date and PX value at top, then create a custom column saying Currency Type". Then the table looks as below:

Kishore_KVN_0-1687193070584.png

3. Now after creating tables like that append them to create third table. Output looks like this:

Kishore_KVN_1-1687193127653.png

 

4. After loading data into Power BI desktop, create a Matrix visual which will creates report as you need. Please refer to below screenshot for the same:

Kishore_KVN_2-1687193202089.png

 

If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!

 

 

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