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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ringovski
Helper II
Helper II

Countrows from Sumx

Hi All,

I conditionaly format a number column if the delivery day exceed the overnight max (agreed SLA) , this is simple enough. Works great highlights the rows which exceed the SLA. Now I need to count them, but I am unable to get this working.

tas 1 format days =
var _delivered = SUMX(toll_shipments, Toll_Shipments[Delivery Days])
var _maxdays = SUMX(Delivery Times Ex Tasmania, Delivery Times Ex Tasmania[Overnight Max])

return
IF(_delivered > _maxdays,"Red","Black")

ringovski_0-1647402610392.png

 

I 've tried using a IF like the intial measure format days but it doesn't work, count days with calculate returns 85 and I'm not sure why and you can see that it should be 8.

tas 1 count days =
var _delivered = SUMX(toll_shipments, Toll_Shipments[Delivery Days])
var _maxdays = SUMX(Delivery Times Ex Tasmania, Delivery Times Ex Tasmania[Overnight Max])

return
Calculate(countrows(toll_shipments),toll_shipments[sender state]="TAS", Toll_Shipments[Shipment Type = "Overnight")

 

Thanks for any assistance.

 

 

4 REPLIES 4
m3tr01d
Continued Contributor
Continued Contributor

hi @ringovski

please, tell us what does toll_shipments data is about. Show us a sample of couple of rows of the table (we need to see the columns Delivery days and Overnight max)

tamerj1
Super User
Super User

Hi @ringovski 

what are you slicing by?

can you please share a screeor you data modrl and your visual blanching out any sensitive data?

amitchandak
Super User
Super User

@ringovski , Try like

 

tas 1 count days =
var _delivered = SUMX(toll_shipments, Toll_Shipments[Delivery Days])
var _maxdays = SUMX(Delivery Times Ex Tasmania, Delivery Times Ex Tasmania[Overnight Max])

return
Calculate(countrows(toll_shipments),filter(toll_shipments, toll_shipments[sender state]="TAS", Toll_Shipments[Shipment Type = "Overnight"))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

A Small screen shot of the data, its pretty simple pick up parcels from one location by State and ship it to another by State then its either Overnight or Off-Peak  (x days).

 

ringovski_0-1647473720555.png

ringovski_2-1647473946805.png

Count the week days between Pick up & Delivered date.

Delivery Days = if( not(isblank([Pick Up Date])) && not(isblank([Actual Delivered Date])),
COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            CALENDAR ( 
                'Toll_Shipments'[Pick Up Date],
                Toll_Shipments[Actual Delivered Date]
                  ),
            "Is Weekday",WEEKDAY([date],2)<6
            ,"Is Holiday", CONTAINS('Holiday Dates','Holiday Dates'[Dates],[Date] )
        ),
        [Is Holiday] = FALSE() 
           && [Is Weekday] = TRUE()
    )
),BLANK())

Then if the delivery days are higher than the overnight max (SLA number) return red. This works great but now I need to count the number of rows which are red.

 

tas 1 format days =
var _delivered = SUMX(toll_shipments, Toll_Shipments[Delivery Days])
var _maxdays = SUMX(Delivery Times Ex Tasmania, Delivery Times Ex Tasmania[Overnight Max])

return
IF(_delivered > _maxdays,"Red","Black")

 

Attempt to count the red rows only, this has a error "True False expression does not specify one column. Each True/False expressions used a table filter expression must refer to exactly one column.

 

tas 1 count days = 
var _delivered = SUMX(Toll_Shipments,Toll_Shipments[Delivery Days])
var _maxdays = sumx('Delivery Times Ex Tasmania','Delivery Times Ex Tasmania'[Overnight Max])

return
IF(_delivered > _maxdays,Calculate(countrows(toll_shipments),filter(toll_shipments, Toll_Shipments[Sender State] = "TAS" && Toll_Shipments[Shipment Type] = "Overnight"),0))

 I've tried a few different combinations and haven't got it work yet.

 

Thanks for any assistance.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.