Forum Discussion

pravind96's avatar
pravind96
Frequent Visitor
6 years ago
Solved

How to correct the Blank into 0 in Card Visual.

Hi, 
I have set a mesure show zero to the card visual when select a particular Status. 
Example, I select status "Healthy" from filter. My other card visual should have change to "0". 

Now, when I select a status, the other card visual remain with same value. It doesn't change to 0.
Here's my current measure that I set:
"Healthy 2 = IF(ISBLANK(CALCULATE(COUNT(Table10[Result 2]), Table10[Result 2] = "Healthy")), 0, CALCULATE(COUNT(Table10[Result 2]), Table10[Result 2] = "Healthy"))"



  • Hi pravind96 ,

     

    We can use the following measures to fix it:

     

    Healthy =
    CALCULATE (
        COUNT ( 'Table10'[Result 2] ),
        'Table10',
        'Table10'[Result 2] = "Healthy"
    ) + 0
    

     

    Infected =
    CALCULATE (
        COUNT ( 'Table10'[Result 2] ),
        'Table10',
        'Table10'[Result 2] = "Infectet"
    ) + 0
    

     

    Precaution =
    CALCULATE (
        COUNT ( 'Table10'[Result 2] ),
        'Table10',
        'Table10'[Result 2] = "Precaution"
    ) + 0
    

     

    Suspected =
    CALCULATE (
        COUNT ( 'Table10'[Result 2] ),
        'Table10',
        'Table10'[Result 2] = "Suspected"
    ) + 0

     

    Add a 'Table10', in the calculate formula.


    Best regards,

     

4 Replies

  • v-lid-msft's avatar
    v-lid-msft
    Icon for Community Support rankCommunity Support

    Hi pravind96 ,

     

    We can use the following measures to fix it:

     

    Healthy =
    CALCULATE (
        COUNT ( 'Table10'[Result 2] ),
        'Table10',
        'Table10'[Result 2] = "Healthy"
    ) + 0
    

     

    Infected =
    CALCULATE (
        COUNT ( 'Table10'[Result 2] ),
        'Table10',
        'Table10'[Result 2] = "Infectet"
    ) + 0
    

     

    Precaution =
    CALCULATE (
        COUNT ( 'Table10'[Result 2] ),
        'Table10',
        'Table10'[Result 2] = "Precaution"
    ) + 0
    

     

    Suspected =
    CALCULATE (
        COUNT ( 'Table10'[Result 2] ),
        'Table10',
        'Table10'[Result 2] = "Suspected"
    ) + 0

     

    Add a 'Table10', in the calculate formula.


    Best regards,

     

    • pravind96's avatar
      pravind96
      Frequent Visitor

      Hi, thanks for the answer. It works. 

      I found this code earlier. It works too.

      Healthy 2 = IF(ISBLANK(CALCULATE(COUNT(Table10[Result 2]), Table10[Result 2] = "Healthy")), 0, CALCULATE(COUNT(Table10[Result 2]), Table10[Result 2] = "Healthy"))
  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Try:

    Healthy 2 = 
    VAR __MyVar =
    	IF(
    		ISBLANK(
    			CALCULATE(
    				COUNT(Table10[Result 2]), 
    				Table10[Result 2] = "Healthy"
    			)
    		), 
    		0, 
    		CALCULATE(
    			COUNT(Table10[Result 2]), 
    			Table10[Result 2] = "Healthy"
    		)
    	)
    RETURN
    	IF(ISBLANK(__MyVar),0,__MyVar)

    If that doesn't work, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

    • pravind96's avatar
      pravind96
      Frequent Visitor

      It's still showing the same results as mine. Other card visual doesn't show 0.