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
ecoast16
Frequent Visitor

Write measure to return result based on type of visual

Hello! I have a oddball one here, i think, but hopefully not... 🙂 I created a measure which counts the new number of trades. I use this value in two ways, one as a KPI card, and other in a table. When I use the measure in the KPI I want the value to return '0' instead of 'blank', but when the measure is used in a table, the desired result is 'blank' so that only records that have data will appear. I know that I could simply build two measures, which I have done; (1) using IFBLANK then '0' for the KPI card, and (2) not using IFBLANK logic for the table. Which i have done below, but I have alot of measures and hate to have two of each one. Thanks for your time!

 

ecoast16_0-1603498905743.png

 

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @ecoast16 

 

You may try creating a measure with ISFILTERED function like below:

Sum 2 = IF(ISFILTERED('Table'[Year]),[Sum],[Sum]+0)

 

In this example, [Sum] is a measure with the desired result 'blank', Year is a column I place in the table. When Year is being filtered directly as in the table visual, then use [Sum], otherwise use [Sum]+0 which will add 0 to blank values.

10272.jpg

This can work as your requirement. But take note that once the column in the ISFILTERED function is filtered and applied to the card visual directly, then it will not work as what you want.

 

Best regards,

Jing

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

amitchandak
Super User
Super User

@ecoast16 ,The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

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.