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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
hmeltonPSL
Helper II
Helper II

Don't include blanks in COUNTROWS

I am trying to get the number of workorders with a Weekoffset =0  (this is the current week)  with the below measure.  I am getting that data but I am also getting all the rows where the weekoffset is blank because the date complete is blank.  I can create a card using filters and adding weekoffset is not blank and get the correct number but when I try to recreate the card as a measure, I can't seem to get rid of the blanks.   I have multiple combos using NOT ISBLANK or BLANK but no luck. Any ideas?  Thank you
 
WOCompCurrentWeek =
COUNTROWS (
    CALCULATETABLE (
        'workorders',
        FILTER (
            'workorders',
            'workorders'[statusid] = 3
        ),
    FILTER (
        'workorders',
        'Workorders'[DivisionType] = "HelpDesk"
    ),
        FILTER (
            'DatesTable',
            ('DatesTable'[Weekoffset] == 0)
        )
    )
)
1 ACCEPTED SOLUTION
pbiuseruk
Resolver II
Resolver II

Hello,

 

Couple notes. If you're using the filter function for the same table, then you can use && or || for multiple conditions. 

Why don't you also say in your condition that complete date can't equal blank (just to test if that works)?

 

Also, I usually make an additional column for my week offset columns which is of a string type and I have a formula in there which says to rename the 0 to "Current Week". I do this because in the line charts or column charts it comes through quite nicely. Also, for all of the other prior weeks I call it Week -X.

View solution in original post

7 REPLIES 7
v-tsaipranay
Community Support
Community Support

Hi [User],

Thanks for reaching out to the Microsoft fabric community forum.

 

You're right the issue is that rows with blank DateComplete values cause Weekoffset to be blank, and those are being included in your count unless explicitly filtered out in the measure.

While using visual-level filters can hide those blanks, DAX measures require that condition to be written directly.

 

Here's the recommended fix:

WOCompCurrentWeek =
CALCULATE (
    COUNTROWS ( 'workorders' ),
    'workorders'[statusid] = 3,
    'workorders'[DivisionType] = "HelpDesk",
    NOT ISBLANK ( 'DatesTable'[Weekoffset] ),
    'DatesTable'[Weekoffset] = 0
)

 

This ensures only work orders from the current week are counted, and blanks are excluded.

Thanks to @pbiuseruk and @Irwan  for the suggestions  especially around filtering logic and data modeling practices.

 

I hope this will resolve your issue, if you need any further assistance, feel free to reach out.

If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

 

Thankyou.

Thanks but I have tried this and I am still getting the wrong numbers.  The corect number is always one less than the measure...which I am guessing is the Blanks count.

pbiuseruk
Resolver II
Resolver II

Hello,

 

Couple notes. If you're using the filter function for the same table, then you can use && or || for multiple conditions. 

Why don't you also say in your condition that complete date can't equal blank (just to test if that works)?

 

Also, I usually make an additional column for my week offset columns which is of a string type and I have a formula in there which says to rename the 0 to "Current Week". I do this because in the line charts or column charts it comes through quite nicely. Also, for all of the other prior weeks I call it Week -X.

So I actually changed by view for the dataset to include only completed workorders and changed the Measure to below and it is now working as expected.  Thanks!

 

WorkordersCompCurrentWeek = COUNTROWS (
CALCULATETABLE (
'completedworkordersonly',
FILTER (
'completedworkordersonly',
'completedWorkordersonly'[DivisionType] = "HelpDesk"
),
FILTER (
'DatesTable',
('DatesTable'[Weekoffset] = 0)
)
)
)

Thanks...I tried added not isblank for datecomplete and it gives me the whole recordset.  I will try your second suggestion.

Irwan
Super User
Super User

hello @hmeltonPSL 

 

i am not sure how you dataset looks like but do you think you can add another measure for removing blank from your countrow measure.

something like below.

COUNTX(
    FILTER(
        'workorders',
        not ISBLANK('DatesTable'[Weekoffset])
    ),
    [WOCompCurrentWeek]
)
 
Otherwise please share your sample dataset and expected outcome.
 
Hope this will help.
Thank you.

Okay...I tried that but get an error on the measure.

 

A single value for column 'weekoffset' in table 'DatesTable' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single......

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.