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
Kan1shk
Regular Visitor

Power BI Custom Filter Creation with DAX or any other inputs?

Hello Community! 🙂

 

How can one set a certain criteria which returns all the wrong format, i.e. which does not match the format like DE followed by 9 digits in Power BI columns? Basically whatever is not matching the defined format, should be displayed. Thank you in advance:)

1 ACCEPTED SOLUTION
Alex_T
Frequent Visitor

Bit rushed earlier, here's an example

 

(_text as text) as logical =>
let

_text_asList = Text.ToList(_text),
_length = 8,
_invalid_chars = Text.ToList("{}[]/\,. ;:'"),
_letters = {"A".."Z"},
fnCheckRange = (_string, _start, _count) as logical =>

let

result = List.ContainsAll(
_letters,
Text.ToList(Text.Middle(_string,_start,_count))
)

in

result,

//__tests__
_not_uppercase = _text <> Text.Upper(_text),
_wrong_length = Text.Length(_text) <> _length,
_contains_invalid_chars = List.ContainsAny(_text_asList,_invalid_chars),
_not_validChars = not fnCheckRange(_text,0,2),
_test_outcome = List.AnyTrue({

_not_uppercase,
_wrong_length,
_contains_invalid_chars,
_not_validChars
})

in

_test_outcome

 

View solution in original post

3 REPLIES 3
Kan1shk
Regular Visitor

@Alex_T  Thank you so much. I was trying to solve the same, I think this should work..

Alex_T
Frequent Visitor

Hi there, this isn't a complete answer but to start you off, you could write an M-query function that tests various components of a string and returns a flag to indicate if it's wrong. You can't do pattern matching so would have to use a combination of text and list functions to test various components, such as 

Hope this helps

Alex_T
Frequent Visitor

Bit rushed earlier, here's an example

 

(_text as text) as logical =>
let

_text_asList = Text.ToList(_text),
_length = 8,
_invalid_chars = Text.ToList("{}[]/\,. ;:'"),
_letters = {"A".."Z"},
fnCheckRange = (_string, _start, _count) as logical =>

let

result = List.ContainsAll(
_letters,
Text.ToList(Text.Middle(_string,_start,_count))
)

in

result,

//__tests__
_not_uppercase = _text <> Text.Upper(_text),
_wrong_length = Text.Length(_text) <> _length,
_contains_invalid_chars = List.ContainsAny(_text_asList,_invalid_chars),
_not_validChars = not fnCheckRange(_text,0,2),
_test_outcome = List.AnyTrue({

_not_uppercase,
_wrong_length,
_contains_invalid_chars,
_not_validChars
})

in

_test_outcome

 

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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 Kudoed Authors