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! Request now

Reply
Anonymous
Not applicable

Need Help: Recognizing inconsistent values

I'm having some issues writing Measures to analyze the below information. What I'm trying to do is create a measure that calls out inconsistencies in the "Unique Contract/Material" row's Pricing units and Units of Measure. For instance, Contract 56000 has an error with Material 44's Pricing Unit. Under this Contract's Material 44, the Pricing Unit shows as both 100 and 1. I need a measure to say, "this is wrong and needs to be checked".

Similarly, Contract 45000 has an error with Material 33's Unit of Measure. Under this Contract's Material 33, the Unit of Measure shows as both LB and Each. I need a measure that call this out as an error as well.

I greatly appreciate the help!!

Unique Contract/MaterialContract Line NumberContractMaterialPricing UnitUnit of Measure
70000_55170000551Each
70000_4427000044100LB
70000_4437000044100LB
56000_5715600057100Each
56000_44256000441LB
56000_4435600044100LB
45000_54145000541000LB
45000_33245000331Each
45000_33345000331LB
32000_54132000541000LB
23000_3312300033100Each
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Sure, seems like the easiest thing to do would be to create a column like:

 

Unit Defect = 
    COUNTROWS(
        DISTINCT(
            SELECTCOLUMNS(
                FILTER(
                    ALL('Table'),
                    [Unique Contract/Material] = EARLIER('Table'[Unique Contract/Material])
                ),
                "Unit of Measure",
                [Unit of Measure]
            )
        )
    )

 

Attached PBIX that has both defect columns.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Sure, seems like the easiest thing to do would be to create a column like:

 

Unit Defect = 
    COUNTROWS(
        DISTINCT(
            SELECTCOLUMNS(
                FILTER(
                    ALL('Table'),
                    [Unique Contract/Material] = EARLIER('Table'[Unique Contract/Material])
                ),
                "Unit of Measure",
                [Unit of Measure]
            )
        )
    )

 

Attached PBIX that has both defect columns.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Thanks for the help. Can you explain what the DAX formula is doing (in long form) so that I can better understand the solution?

Sure, you read it inside out.

 

Use ALL to remove row context and then filter that down so that your Unique Contract/Material equals your current row's value for Unique Contract/Material (EARLIER). Side note, EARLIER is perhaps the worst named DAX function in all of DAX. Now, use SELECTCOLUMNS to just select the column of interest, like Unit of Measure. Now, use DISTINCT to return the distinct (unique) values in this single column table returned from SELECTCOLUMNS. Now use COUNTROWS to count the number of rows. 

 

So, at the end of the day, you have the count of unqiue values within your column of interest. If it is more than 1 = bad. 🙂



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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
Top Kudoed Authors