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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
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