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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Seeker201
New Member

DAX Help Needed for Complex Data Validation

 
7 REPLIES 7
Anonymous
Not applicable

Hi @Seeker201,

It seems like you removed the detail requirement from the thread. Can you please share some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Notice: please not attach sensitive data in shared dummy data.

Regards,

Xiaoxin Sheng

ERD
Community Champion
Community Champion

Hello @Seeker201 ,

Unfortunately, there is no description in the topic you've provided. Please, add the description, some demo data (a fake one that resembles your real one) and a desired output.

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

tamerj1
Super User
Super User

@Seeker201 
You have deleted the description. Please let me know if it is a data confidentiality issue. 
However, I lost track of the conditions so the following may not be accurate but it describes the general idea on how to perform complex data validation.

I would also recommend to store numbers, letters, special characters in manually created tables. That would make the DAX much cleaner.
Note: Another method which implies a "Cause & Effect Matrix" which is a pivoted table, may also be used to serve the same purpose but I guess won't be required in this scenario.

1.png

Test2 = 
VAR SpecialCharacters = { "~", "@", "#", "$", "%", "^", "*", "(", ")", "_", "-", "+", "=", ":", ";", "'", "\", "/", "|", "{", "}", "[", "]", "?", ",", ".", "<", ">", "!", "`", "  " }
VAR Letters = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }
VAR Numbers = SELECTCOLUMNS ( GENERATESERIES ( 0, 9, 1 ), "Number", [Value] & "" )
RETURN
    COUNTROWS ( 
        FILTER ( 
            CustomerContactQuality,
            VAR String = CustomerContactQuality[CustomerAddress]
            VAR Length = COALESCE ( LEN ( String ), 1 )
            VAR T1 = GENERATESERIES ( 1, Length, 1 )
            VAR T2 = SELECTCOLUMNS ( T1, "@Letter", MID ( String, [Value], 1 ) )
            VAR NotEmpty = String <> BLANK ( )
            VAR ContainsSpecialCharacters = NOT ISEMPTY ( INTERSECT ( SpecialCharacters, T2 ) )
            VAR ContainsNumbers = NOT ISEMPTY ( INTERSECT ( Numbers, T2 ) )
            VAR DoesNotContainLetters = ISEMPTY ( INTERSECT ( Letters, T2 ) )
            RETURN
                IF ( NotEmpty && ContainsSpecialCharacters, ContainsNumbers || DoesNotContainLetters, FALSE )
        )
    )
Dangar332
Super User
Super User

hi, @Seeker201 
try below code 

Malformed Address =
IF(CustomerContactQuality[CustomerAddress]<> BLANK() || OR(
    OR(
    NOT(CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"1") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"2") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"3") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"4") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"5") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"6") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"7") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"8") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"9") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"0") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],",") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"'") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],".") &&
        CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"-")),CONTAINSSTRING(CustomerContactQuality[CustomerAddress],"  ")),
        LEN(CustomerContactQuality[CustomerAddress]) <= 10)
        ,"BAD AD","GOOD AD")
and yah! you say about no letter found in the field i don't understand which letter you talk about
 
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
tamerj1
Super User
Super User

Hi @Seeker201 

can you provide a couple of examples describing the expected result?

Hi @tamerj1 

As of now, I don't have a specific expected result for that, but I have provided clear logic for the requirement
related to malformed addresses in my model, which is based on the customeraddress column

If you could provide me with the DAX  for both requirements, it would be greatly appreciated

@Seeker201 

I requested an example because I don't have access now to my laptop to open your ssmple file. Perhaps one example would help draft a code without having to look into the file. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.