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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
zahidah_mabd
Helper I
Helper I

Count the value that does not starts with a certain number

Hi, I want to count the number of data that does not begins with a certain value.

The valid position code begins with either "0" or "10000" so any code that does not begins with any of those two digits is considered invalid.

Example:
02789220 (valid)
10000568 (valid)
24876490 (invalid)
556 (invalid)

How do I create a measure that counts the number of invalid position code?

This is the measure that I created but it doesnt really gave the correct result. It ended up counting the total data which is wrong. 

Sum Invalid Position Code = 

CALCULATE(countrows(Filter('zhpla 2022', left('zhpla 2022'[Position Code],1) <> "0" || left('zhpla 2022'[Position Code],5) <> "10000" ))) + 0

Can anyone help me?

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @zahidah_mabd ,

According to your description, you should use && but not || in your code, modify it to:

Sum Invalid Position Code =
CALCULATE (
    COUNTROWS (
        FILTER (
            'zhpla 2022',
            LEFT ( 'zhpla 2022'[Position Code], 1 ) <> "0"
                && LEFT ( 'zhpla 2022'[Position Code], 5 ) <> "10000"
        )
    )
) + 0

Get the correct result.

vkalyjmsft_0-1653379016579.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

View solution in original post

3 REPLIES 3
v-yanjiang-msft
Community Support
Community Support

Hi @zahidah_mabd ,

According to your description, you should use && but not || in your code, modify it to:

Sum Invalid Position Code =
CALCULATE (
    COUNTROWS (
        FILTER (
            'zhpla 2022',
            LEFT ( 'zhpla 2022'[Position Code], 1 ) <> "0"
                && LEFT ( 'zhpla 2022'[Position Code], 5 ) <> "10000"
        )
    )
) + 0

Get the correct result.

vkalyjmsft_0-1653379016579.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

It worked! Thank you sooo much 🙂

danextian
Super User
Super User

Hi @zahidah_mabd ,

First, I woud create a calculated column that determines whether the start of a value is zero or not. That would be

 

 

Zero =
LEFT ( Table[Column], 1 ) = "0"
    || LEFT ( Table[Column], 5 ) = "10000"
//this assumes that column is a text type

 

 

Then a measure to count the number of rows

 

 

Row Count =
CALCULATE ( COUNTROWS ( Table ), FILTER ( Table, Table[Zero] = TRUE () ) )

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors