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

Dividing totals of 2 columns as they are filtered ?

I have a table visual with 2 columns (A, B), and the table is filtered by dates and by sales associate.

Each column shows a TOTAL amount at the bottom of the table.

I would like to produce a 3rd table column that divides the TOTALS shown by the table e.g. (B/A).

The 3rd column value should change as I use the filters with different dates and different sales associates.

Thanks

 

9 REPLIES 9
mahoneypat
Employee
Employee

This should work (replacing Table and column with your actual names.

 

NewMeasure = DIVIDE(SUM(Table[Column1]), SUM(Table[Column2]))

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks. Sorry but it didn't work.

The 5th column to the right has to be the total (153.8 divided by 142.7), so the 5th column total should be 107.83.

I can't group this because the 5th total should be based on random filtering by associate # and by dates range.

kriman_0-1604442189666.png

 

Can you explain more about the direct_hours and Earn columns?  Are those columns or measures?  Do you have a single table in your model?


Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks.

They are forecasted hours Vs actual hours of work, displayed in the table and filtered ramdomly by date range & associate ID #.

Yes, data coming from single table.

Is there an aggregation on the direct_hours and earn columns? or are those the row values?  If so, what aggregation?

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Aggregations, yes.

A single day, might have several rows. So the displayed table shows a sum of each day.

 

You didn't say which aggregation so I assume it is a SUM.  Try this expression instead

 

NewMeasure =
SUMX (
    SUMMARIZE (
        Table,
        Table[assoc_id],
        Table[activity_date]
    ),
    CALCULATE (
        DIVIDE (
            SUM ( Table[EARN] ),
            SUM ( Table[direct_hours] )
        )
    )
)

 

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi,

 

Sorry, no luck. 

Result is 52.2, but it should be 107.83.

________________________________________________

Perfor% =
SUMX (
SUMMARIZE (tblWorkHistory,
tblWorkHistory[assoc_id],
tblWorkHistory[activity_date]
),
CALCULATE (
DIVIDE (
SUM ( tblWorkHistory[EARN]), SUM(tblWorkHistory[direct_hours])
 
)))

Hi @kriman 

 

I test this with two measures as below and both of them work well. 

Measure = SUM('Table'[EARN])/SUM('Table'[direct_hours])
Measure 2 = DIVIDE(SUM('Table'[EARN]),SUM('Table'[direct_hours]))

11063.jpg

I noticed that the total value 68.77 in your screenshot is nearly the sum total of the values above it, and the Perfor % value in every row is not calculated correctly, so I guess if there is any typo in your measure? Can you please check it and try again?

11064.png

Best Regards,

Community Support Team _ Jing Zhang

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

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.