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
clarkey1988
Helper II
Helper II

Count Rows based on a value in a column

Hi,

 

I'm wondering if anyone can help.

 

I am trying to divide the $ amount in route revenue evenly by the number of rows an order header number has.

 

So in the first example below it would be $1,024.52 / 8 rows = $128.07

 

The second example would be $1,000 / 4 rows = $250

 

Currently, each row is pulling the total revenue ($1,024.52) for an order, but I need it split between each row.

 

I have been playing around with the count rows function, but keep getting errors.

 

RouteNumberStop Numberord_hdrnumberLegHeaderEndDateWeek NumberRoute RevenueSplit Revenue
MAA015P1437532721363819/28/2020 16:2640$1,024.52 $            128.07
MAA015P1437533221363819/28/2020 16:2640$1,024.52 $            128.07
MAA015P1437533021363819/28/2020 16:2640$1,024.52 $            128.07
MAA015P1437532821363819/28/2020 16:2640$1,024.52 $            128.07
MAA015P1437532621363819/28/2020 16:2640$1,024.52 $            128.07
MAA015P1437533121363819/28/2020 16:2640$1,024.52 $            128.07
MAA015P1437532921363819/28/2020 16:2640$1,024.52 $            128.07
MAA015P1437532521363819/28/2020 16:2640$1,024.52 $            128.07
     $8,196.20$1,024.52
       
       
MAA024V123421845639/30/2020 19:3048$1,000.00 $            250.00
MAA024V123521845639/30/2020 19:3048$1,000.00 $            250.00
MAA024V123621845639/30/2020 19:3048$1,000.00 $            250.00
MAA024V123721845639/30/2020 19:3048$1,000.00 $            250.00
     $4,000.00$1,000.00

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @clarkey1988 

Try this for a calc column:

Split Revenue V2 =
DIVIDE (
    Table1[Route Revenue],
    CALCULATE (
        COUNT ( Table1[ord_hdrnumber] ),
        ALLEXCEPT ( Table1, Table1[ord_hdrnumber] )
    )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

3 REPLIES 3
AlB
Community Champion
Community Champion

Hi @clarkey1988 

Try this for a calc column:

Split Revenue V2 =
DIVIDE (
    Table1[Route Revenue],
    CALCULATE (
        COUNT ( Table1[ord_hdrnumber] ),
        ALLEXCEPT ( Table1, Table1[ord_hdrnumber] )
    )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Hi @AlB , I appreciate your help.

 

That worked. I received your message and will respond. I do have a quick follow up. I believ eit's similar to the above.

 

I have a specific route number called Nestle-12 that I invoice $14,100 each week. I again need to divide this $14,100 by the number of orders for Nestle-12 for that given week. So the example below would be $14,100/9 = $1,566.67 each row.

 

It's similar to the above but it's specific to a route number and week number.

 

clarkey1988_0-1609966503578.png

 

 

AlB
Community Champion
Community Champion

@clarkey1988 

Yes, if it's specific to route  and week number, you just have to reflect that on the ALLEXCEPT... and let context transition work its magic:

Split Revenue V3 =
DIVIDE (
    Table1[Route Revenue],
    CALCULATE (
        COUNT ( Table1[ord_hdrnumber] ),
        ALLEXCEPT ( Table1, Table1[RouteNumber], Table1[WeekNumber]  )
    )
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

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.