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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calulations with table values

Hi experts!
After doing lot of research in this forum and with the help of some of you, I have built a data table (see attached the pbix file);which shows the productivity in % for diferent machines and differente locations. But this brings me to a final step that Im not able to solve it by myself.
What I am trying to do is to take out from the table below, just the result from Madrid (70,89%) and Barcelona (83,92%) and consolidate both results weighting them according to "total production" measure.

( 70,89% x 52.550 + 83,92 x 135.100 ) / ( 52.550 + 135.100 ) = 80,27%

Here are my measures:

Total Production = sum(Database[Production])

Total Working Hours = sum(Database[Working Hours])

TotalExpectedProduction = sum(Database[Expected Production])

Avexpectedprod = divide(sumx(Database;[TotalExpectedProduction]*[Total Working Hours]);sum(Database[Working Hours]))

YTD Productivity =
CALCULATE (
    DIVIDE (
        SUMX (
            SUMMARIZE (
                Database;
                Database[Matchine];
                "AA"; [Total Production] / ( [Total Working Hours] * [Avexpectedprod] )
            );
            [AA] * [Total Working Hours]
        );
        [Total Working Hours];
        0
    );
    DATESYTD ( Calendar[Date]; "30/06" );
    FILTER (
        ALL ( 'Calendar' );
        'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
            && 'Calendar'[Fiscal Year] = MAX ( 'Calendar'[Fiscal Year] )
    )
)

The tadabase format

 

DataTable.PNG

The output in matrix table and the result that I need to achieve:

 

Sin título.png

Thank you very much for your support

Reub

1 ACCEPTED SOLUTION
Anonymous
Not applicable

done!!!

New2 =
DIVIDE (
    CALCULATE (
        SUMX ( VALUES ( Database[Location] ); [YTD Productivity] * [Total Production] );
        Database[Location] = "Barcelona"
            || Database[Location] = "Madrid"
    );
    CALCULATE (
        SUM ( Database[Production] );
        Database[Location] = "Barcelona"
            || Database[Location] = "Madrid"
    )
)

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

First step done!!

New = divide(sumx(values(Database[Location]); [YTD Productivity]*[Total Production]);[Total Production])

Thanks to @MattAllington that published this post https://community.powerbi.com/t5/Desktop/Subtotaling-with-SUMX-and-Summarize/td-p/216724

Now I have to figure it out how to filter "Madrid" and "Barcelona" in the measure (not with filter panel)

Thank you!!!

Anonymous
Not applicable

done!!!

New2 =
DIVIDE (
    CALCULATE (
        SUMX ( VALUES ( Database[Location] ); [YTD Productivity] * [Total Production] );
        Database[Location] = "Barcelona"
            || Database[Location] = "Madrid"
    );
    CALCULATE (
        SUM ( Database[Production] );
        Database[Location] = "Barcelona"
            || Database[Location] = "Madrid"
    )
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.