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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Ramees_123
Helper IV
Helper IV

Table transformation logic in power bi

3tables.PNGIn In my business logis sales are happening in 3 phases, first customer order will come in to the inbound after production it moves in to outbound and at last it reached in the completed(Day Sale). How to achieve if it moves from inbound to outboud the sales order and line should not exist in the inbound, if it moves from outbound to complete it should not exist in the outbound, how i can achieve this in power bi transformation table. depending on the sales order and line it is moving throuhg the phases.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Ramees_123 ,

 

I create a simple .pbix file. Please check if this is what you want.

 

1. Import your data.

2. Create another 3 tables like so:

 

let
    Source = #"Inbound",
    #"Filtered Rows" = Table.SelectRows(Source, each ([status] = "Inbound"))
in
    #"Filtered Rows"

 

inbound - desired.JPG

 

 

let
    Source = #"Inbound",
    OnlyIncludeOutbound = Table.SelectRows(Source, each ([status] = "Outbound")),
    AppendOutbound = Table.Combine({OnlyIncludeOutbound, #"Outbound"}),
    ReturnOutbound = Table.SelectRows(AppendOutbound, each ([status] = "Outbound"))
in
    ReturnOutbound

 

outbound - desired.JPG

 

 

let
    Source = #"Outbound",
    OnlyIncludeCompleted = Table.SelectRows(Source, each ([status] = "Completed")),
    AppendCompleted = Table.Combine({OnlyIncludeCompleted, #"Completed"}),
    ReturnCompleted = Table.SelectRows(AppendCompleted, each ([status] = "Completed"))
in
    ReturnCompleted

 

completed - desired.JPG

 

2. Uncheck "Enable load" of each original table.

Icey_0-1604477411931.png

 

For more details, please check the attached .pbix file.

 

 

Best regards

Icey

 

If this post helps,then consider Accepting it as the solution to help other members find it faster.

View solution in original post

4 REPLIES 4
msksenthil
Helper III
Helper III

@Ramees_123 

I believe you have unique fields like customer_id/sales_id and date_field in all the tables

With that, you can merge the tables from the 'Inbound' table to the 'Outbound' table and to the 'Completed' table

And expand table particularly the date from each table

So the final table has all the 3 dates

Disable load the other 3 tables

Create a custom column based on the 3 dates to find the record is Inbound/Outboud/Completed

 

finally, you can create a measure based on a custom column and find the number of orders

 

Here the M-code for Merge/final table

let
Source = Table.NestedJoin(Inbound, {"customer order", "saleorder"}, Outbound, {"customer order", "saleorder"}, "Outbound", JoinKind.LeftOuter),
#"Expanded Outbound" = Table.ExpandTableColumn(Source, "Outbound", {"out_createddate"}, {"out_createddate"}),
#"Merged Queries" = Table.NestedJoin(#"Expanded Outbound", {"customer order", "saleorder"}, Completed, {"customer order", "saleorder"}, "Completed", JoinKind.LeftOuter),
#"Expanded Completed" = Table.ExpandTableColumn(#"Merged Queries", "Completed", {"comp_createddate"}, {"comp_createddate"}),
#"Added Custom" = Table.AddColumn(#"Expanded Completed", "Custom", each try if Int64.From([comp_createddate]) > 0 then "Completed" else "no" otherwise try if Int64.From([out_createddate]) > 0 then "Outbound" else "Inbound" otherwise "Inbound")
in
#"Added Custom"

 

 

Please share your results

Icey
Community Support
Community Support

Hi @Ramees_123 ,

 

I create a simple .pbix file. Please check if this is what you want.

 

1. Import your data.

2. Create another 3 tables like so:

 

let
    Source = #"Inbound",
    #"Filtered Rows" = Table.SelectRows(Source, each ([status] = "Inbound"))
in
    #"Filtered Rows"

 

inbound - desired.JPG

 

 

let
    Source = #"Inbound",
    OnlyIncludeOutbound = Table.SelectRows(Source, each ([status] = "Outbound")),
    AppendOutbound = Table.Combine({OnlyIncludeOutbound, #"Outbound"}),
    ReturnOutbound = Table.SelectRows(AppendOutbound, each ([status] = "Outbound"))
in
    ReturnOutbound

 

outbound - desired.JPG

 

 

let
    Source = #"Outbound",
    OnlyIncludeCompleted = Table.SelectRows(Source, each ([status] = "Completed")),
    AppendCompleted = Table.Combine({OnlyIncludeCompleted, #"Completed"}),
    ReturnCompleted = Table.SelectRows(AppendCompleted, each ([status] = "Completed"))
in
    ReturnCompleted

 

completed - desired.JPG

 

2. Uncheck "Enable load" of each original table.

Icey_0-1604477411931.png

 

For more details, please check the attached .pbix file.

 

 

Best regards

Icey

 

If this post helps,then consider Accepting it as the solution to help other members find it faster.

amitchandak
Super User
Super User

@Ramees_123 , Is that not happening in your source system

No, its not happening in our source system, this should implement by using the power bi logic. the shared youtube videos not discussing this logic.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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