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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

DAX function to check if data is consistent

Hi there!

 

I have a huge table with employee data from two data sources (SharePoint, SAP).

My data looks like this:

IDNameCCEntry dateLeaving dateDivBUQuitting reasonQuitting typeWork hoursFTELocationPositionDataSource
563475Paul Smith7310212019. 03. 04.2021. 04. 18.FinanceMCCKresignationVoluntary401TorontoApplication AdministratorSharePoint
563475Paul Smith7310212019. 03. 04.2021. 04. 18.FinanceMCCKresignationVoluntary401TorontoApplication AdministratorSAP

I need to compare the data from the two sources. I need a function that compares the two rows for each employee and checks if there's difference in any column apart from the DataSource. 

The output should be in a new column that indicates if there's an inconsistency in the data. It would be nice if there's a possibility to color the cells with the deviations or something like this.

Any idea how to achive this with DAX?

Thanks a lot.

 

1 ACCEPTED SOLUTION

@Anonymous 
This is the code for a calculated column

 

Any Differences? = 
VAR DistinctRows =
    COUNTROWS (
        DISTINCT (
            CALCULATETABLE (
                SELECTCOLUMNS (
                    'Employee Data',
                    "@Name", [Name], "@CC", [CC], "@EntryDate", [Entry date], "@LeavingDate", [Leaving date],
                    "@@Div", [Div], "@BU", [BU], "@QuittingReason", [Quitting reason], "@QuittingType", [Quitting type],
                    "@WorkingHours", [Work hours], "@FTE", [FTE], "@Location", [Location], "@position", [Position]
                ),
                ALLEXCEPT ( 'Employee Data', 'Employee Data'[Name] )
            )
        )
    )
RETURN
    IF ( DistinctRows = 2, "Yes", "" )

 

1.png

View solution in original post

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

DAX is for calculation whereas PQ is for such data cleansing/shaping tasks.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

tamerj1
Super User
Super User

@Anonymous 
Not sure what exactly you're looking for but following is one way of doing that.

1.png

Differences? = 
VAR DistinctRows =
    COUNTROWS (
        DISTINCT (
            FILTER (
                ALLEXCEPT ( 'Employee Data', 'Employee Data'[DataSource] ),
                'Employee Data'[ID] = SELECTEDVALUE ( 'Employee Data'[ID] )
            )
        )
    )
RETURN
    IF ( DistinctRows = 2, "Yes", "" )
Anonymous
Not applicable

I get the following error trying your solution: 

A circular dependency was detected: Employee_Data[Differences?].

The output should be a new column in the data source table as you did it. 

It would be useful to have an additional column, which is empty by default, but in case of difference it would show the name of the column that differs.

@Anonymous 
This is the code for a calculated column

 

Any Differences? = 
VAR DistinctRows =
    COUNTROWS (
        DISTINCT (
            CALCULATETABLE (
                SELECTCOLUMNS (
                    'Employee Data',
                    "@Name", [Name], "@CC", [CC], "@EntryDate", [Entry date], "@LeavingDate", [Leaving date],
                    "@@Div", [Div], "@BU", [BU], "@QuittingReason", [Quitting reason], "@QuittingType", [Quitting type],
                    "@WorkingHours", [Work hours], "@FTE", [FTE], "@Location", [Location], "@position", [Position]
                ),
                ALLEXCEPT ( 'Employee Data', 'Employee Data'[Name] )
            )
        )
    )
RETURN
    IF ( DistinctRows = 2, "Yes", "" )

 

1.png

@Anonymous 
This is a measure code not a calculated column.

tamerj1
Super User
Super User

Hi @Anonymous 

How does the report look like? or just the same as the data sorce table?

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!

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.