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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Oblomov
Frequent Visitor

Return specific value as default when IF statement is FALSE

Hello all,

 

 

I have a dashboard featuring both a Table visualization of investments, and a corresponding Card visualization which displays the return for a specific investment when that particular investment is selected in the table.

 

However, when NO investment is selected (ie, the user clicks somewhere outside the table), I would like the Card to default to the return for the TOTAL group of investments.  

 

I'm using the following formula:

IF( HASONEVALUE('Investment Name'), VALUES('Investment Return') )

 

As you can see, when the IF statement is false, it returns a blank; Is there some way I can change the false result to return a specific field for a specific row?

3 REPLIES 3
Anonymous
Not applicable

Yes, you can use the nested usage of IF. 

 

Example: IF( Condition1, True,IF(Condition2,True).

 

You can use SWITCH function as well.

 

Thanks
Raj

Thank you for your reply rajendran, but I think maybe I wasn't clear in my question...I am having trouble in figuring out how to specify exactly which row to return. 

 

I've tried a CALCULATE function where I specify the row (which we'll call TOTAL RETURN), but it is still pulling a blank (although the formula is still performing correctly when I select an individual investment).

Anonymous
Not applicable

Hi @Oblomov

Ok, since no sample data / data model is given, am giving the sample code for your requirement. 

 

Your_Field= 

VAR inFilter= CALCULATE( MAX(Table1.column1), FILTER(Table1,Table1[column2]="Investment Type"))

Return 

IF( HASONEVALUE('Investment Name'), VALUES('Investment Return') ,inFilter)

 

Hope this helps.

 

Thanks

Raj

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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