Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi All,
Below is the table and the following formula is used in excel. The logic is straightforward in excel. I am trying to find the Gender based on values present in column A and B.
Formula - =IF(A2=B2,"No Data",IF(A2="","Female","Male"))
Now, I try to do the same in power BI with similar data, the query doesnt work. I read IF statements work in Power BI.
Following queries have been tried by creating a custom column:
Query 1:
Gender = if([FEMALE_AGE_RANGE]=[MALE_AGE_RANGE],"No Data", if([FEMALE_AGE_RANGE]="null","Male","Female")
Query 2:
Gender = if [FEMALE_AGE_RANGE]=[MALE_AGE_RANGE]
then "No Data"
else if( [FEMALE_AGE_RANGE]="null"
then "male"
else "female"
Can someone please guide me what I am doing wrong and appreciate if someone can provide me a right query using IF statement.
Thank you
Solved! Go to Solution.
Hi @Anonymous ,
try
if [FEMALE_AGE_RANGE] = [MALE_AGE_RANGE]
then "No Data"
else
if [FEMALE_AGE_RANGE] = null
then "Male"
else
"Female"
Hi @Anonymous ,
try
if [FEMALE_AGE_RANGE] = [MALE_AGE_RANGE]
then "No Data"
else
if [FEMALE_AGE_RANGE] = null
then "Male"
else
"Female"
Hi @mussaenda
Thanks for this. It worked so the only difference between your query and my query is that extra space between "else" and "if" 😐 ? and how did you find out about this issue? I did not even think in your direction at all. Thanks again
Hi @Anonymous ,
Glad it worked. It is still your query.
The difference is the null that you treated as a string because of ""
It should be null and not "null"
Thanks mate. Clear 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
30 | |
25 | |
24 | |
13 | |
9 |
User | Count |
---|---|
24 | |
19 | |
16 | |
13 | |
9 |