Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I have used an if formula to matches the values from two different columns and want to return "Y" and "N" based on matched value but for 0 and blank it is showing "Y" that means matched but I it should be "N" since 0 and blank is not matching. I have attached the screenshot and DAX code.
Looking for expert suggetions and opinions.
DAX -
Solved! Go to Solution.
Hi
You need to take into account that the blanks are being treated as zeros in your comparions. One way to do it is with the ISBLANK() function. A solution could be a calculated column like this:
Matched 1 =
VAR blank1 = IF(ISBLANK('Table'[System 1]),1)
VAR blank2 = IF(ISBLANK('Table'[System 2]),1)
VAR _comparison =
SWITCH(
TRUE(),
blank1+blank2 = 2, "Y",
blank1+blank2 = 1, "N",
'Table'[System 1]='Table'[System 2], "Y",
'Table'[System 1]<>'Table'[System 2], "N"
)
RETURN _comparison
Here, I create two variables that check if each column is blank and returns a 1 if that is the case. Then I use SWITCH to determine the comparisons: if both are blank they are similar ("Y"), if only one is blank they are different ("N"), and if there are no blanks they need to actually be compared. This returns:
Hope this helps!
Hi
You need to take into account that the blanks are being treated as zeros in your comparions. One way to do it is with the ISBLANK() function. A solution could be a calculated column like this:
Matched 1 =
VAR blank1 = IF(ISBLANK('Table'[System 1]),1)
VAR blank2 = IF(ISBLANK('Table'[System 2]),1)
VAR _comparison =
SWITCH(
TRUE(),
blank1+blank2 = 2, "Y",
blank1+blank2 = 1, "N",
'Table'[System 1]='Table'[System 2], "Y",
'Table'[System 1]<>'Table'[System 2], "N"
)
RETURN _comparison
Here, I create two variables that check if each column is blank and returns a 1 if that is the case. Then I use SWITCH to determine the comparisons: if both are blank they are similar ("Y"), if only one is blank they are different ("N"), and if there are no blanks they need to actually be compared. This returns:
Hope this helps!
Thank you so much. It worked for me and marked it as solution.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |