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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Calculation for matching

 

 

 

 

I have 2 tables, both have month names and the same location name. However, the tables cannot be merged, nor can I create a relationship between then because of many-to-many.

As an example:

Table1 contains values representing "Downtime"

 JanuaryFebruaryMarchAprilMay
Dallas15661914337333603177
Austin2112290517273132943
Houston5645130918491167984

 

Table2 contains values representing "ScheduledTime"

 JanuaryFebruaryMarchAprilMay
Dallas21392288286131282972
Austin36493132344731113128
Houston33432622316331173111

 

I need to create a measure that would be:

 

 

 

DIVIDE( DIVIDE( SUM(TABLE1[Downtime]), SUM(TABLE2[ScheduledTime))), 60)

 

 

 

This is not working though, the resulted numers are all wrong.  If I do it manually in the calculator, I get the correct result.  

 

So for January of Dallas, my answer should be

(1566 / 2139) / 60 = .0122

I also tried creating a column in Table2 using the same calculation, and the resulted value was the same the entire way down the table. 

 

How can I calculate this accurately? 

1 ACCEPTED SOLUTION
jennratten
Super User
Super User

Hello - this is one way you can accomplish the result with Power Query...

 

Create a new table in Power Query that combines the two tables and performs the division.  

 

let
    Source = Table.NestedJoin (
        Table.UnpivotOtherColumns(Table1, {"Location"}, "Month", "Downtime"), 
        {"Location", "Month"}, 
        Table.UnpivotOtherColumns(Table2, {"Location"}, "Month", "ScheduledTime"), 
        {"Location", "Month"}, "Table", JoinKind.LeftOuter
    ),
    Expand = Table.ExpandTableColumn ( Source, "Table", {"ScheduledTime"}),
    #"Inserted Division" = Table.AddColumn(Expand, "Division", each [Downtime] / [ScheduledTime], type number)
in
    #"Inserted Division"

jennratten_1-1655730253917.png

 

 

 

View solution in original post

1 REPLY 1
jennratten
Super User
Super User

Hello - this is one way you can accomplish the result with Power Query...

 

Create a new table in Power Query that combines the two tables and performs the division.  

 

let
    Source = Table.NestedJoin (
        Table.UnpivotOtherColumns(Table1, {"Location"}, "Month", "Downtime"), 
        {"Location", "Month"}, 
        Table.UnpivotOtherColumns(Table2, {"Location"}, "Month", "ScheduledTime"), 
        {"Location", "Month"}, "Table", JoinKind.LeftOuter
    ),
    Expand = Table.ExpandTableColumn ( Source, "Table", {"ScheduledTime"}),
    #"Inserted Division" = Table.AddColumn(Expand, "Division", each [Downtime] / [ScheduledTime], type number)
in
    #"Inserted Division"

jennratten_1-1655730253917.png

 

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.