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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Filter 2 Columns In A Table Into A Single Column With True/False

Greetings All - 

 

I've recently inherited a PowerBI desktop report where I need to make some changes. From a high level, I need to compare two columns in a single table and return a value of 'True' if the values match. If not, then the value would be 'False' - the trues and falses could be 1's and 0's, or yes's and no's if that works better. However, both columns contain blanks (or nulls) and I only want to perform the comparison on the two columns where the cells have numerical values in them. I need this to happen on a row by row basis. The previous owner created a conditional column to perform the comparison, but didn't filter out the blanks in each column thus creating false "True's" so to speak. The M code and screenshot are below:

tharp02_2-1640621119466.png

tharp02_0-1640620019231.png

 

In PowerQuery, this is what it looks like:

tharp02_1-1640620414529.png

 

What I'd like to do is turn the conditional column "Matching Primary and Billed" into a calculated column using a single DAX expression that compares the values in EMPLOYEE_ID and E_PRIMARY_EMPLOYEE_ID and return a True if they match, a FALSE if they don't and only for the values in both columns that have a numerical value in them (ignoring the nulls/blanks).  I'm guessing some combination of IF(ISBLANK and/or FILTER functions may be involved but I'm uncertain of the correct syntax in this case. Any guidance would be appreciated.

 

Thank you.

 

 

 

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , in DAX

if(not(isblank([EMPLOYEE_ID])) && Not(isblank( [E_PRIMARY_EMPLOYEE_ID] )) && [EMPLOYEE_ID] =[E_PRIMARY_EMPLOYEE_ID]  , true(), false() )

 

in power query

 

if [EMPLOYEE_ID] <> null  and [E_PRIMARY_EMPLOYEE_ID] <> null  and  [EMPLOYEE_ID] =[E_PRIMARY_EMPLOYEE_ID]  then true else  false  

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi Amit - 

 

This is getting closer but it still returns a value even when one or both columns have blank values in them. Is there a way to perform this comparison but leave the cell blank if one or both columns contain a blank?

Hi @Anonymous 

If you want to perform this comparison but leave the cell blank, try this,

DAX code:

Column = 
IF (
    NOT ( ISBLANK ( 'Table'[EMPLOYEE_ID] ) )
        && NOT ( ISBLANK ( 'Table'[E_PRIMARY_EMPLOYEE_ID] ) )
            && 'Table'[EMPLOYEE_ID] = 'Table'[E_PRIMARY_EMPLOYEE_ID],
    1,
    BLANK ()
)

M code:

if [EMPLOYEE_ID] <> null and [E_PRIMARY_EMPLOYEE_ID] <> null  and  [EMPLOYEE_ID] =[E_PRIMARY_EMPLOYEE_ID]  then 1 else  null  // M code, in power query

vxiaotang_1-1641454566113.png

 

 

 

 

Best Regards,

Community Support Team _Tang

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

ALLUREAN
Solution Sage
Solution Sage

Hi, @Anonymous 

 

Did you try first clean the columns (trim, remove duplicates)?

 




Did I answer your question? Mark my post as a solution!


https://allure-analytics.com/
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
https://www.linkedin.com/company/77757292/

Proud to be a Super User!




Anonymous
Not applicable

Hi Allurean. Unfortunately, I can't remove rows where one or both of those columns contain a blank value in the cell as other measures/columns in the report use those rows.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.