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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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