Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DAX Comparison Operations

Hi all,

 

Can anyone help with the following issue - I'm wanting a card to display 0 if another visual is filtered, else show result of calculation;

 

Satisfaction % =
if(isfiltered(SentimentScore[Sentiment])="Negative",0,
CALCULATE(count('SentimentScore'[MessageID]),'SentimentScore'[Sentiment]<>"Negative")
/count('SentimentScore'[MessageID]))
 
Recieving the 'do not support comparing values of type True/False with values of type text.
 
Thanks,
Rob
 
 
  • Hi Anonymous 

     

    Modify your measure like below. The return value of ISFILTERED() is True/False, which cannot be compared with "Negative".

    Satisfaction % =
    IF (
        ISFILTERED ( 'SentimentScore'[Sentiment] )
            && SELECTEDVALUE ( 'SentimentScore'[Sentiment] ) = "Negative",
        0,
        CALCULATE (
            COUNT ( 'SentimentScore'[MessageID] ),
            'SentimentScore'[Sentiment] <> "Negative"
        )
            / COUNT ( 'SentimentScore'[MessageID] )
    )

     

    Kindly let me know if this helps.

    Community Support Team _ Jing Zhang
    If this post helps, please consider Accept it as the solution to help other members find it.

2 Replies

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi Anonymous 

     

    Modify your measure like below. The return value of ISFILTERED() is True/False, which cannot be compared with "Negative".

    Satisfaction % =
    IF (
        ISFILTERED ( 'SentimentScore'[Sentiment] )
            && SELECTEDVALUE ( 'SentimentScore'[Sentiment] ) = "Negative",
        0,
        CALCULATE (
            COUNT ( 'SentimentScore'[MessageID] ),
            'SentimentScore'[Sentiment] <> "Negative"
        )
            / COUNT ( 'SentimentScore'[MessageID] )
    )

     

    Kindly let me know if this helps.

    Community Support Team _ Jing Zhang
    If this post helps, please consider Accept it as the solution to help other members find it.

  • Hi Anonymous ,

     

    Replcae your DAX with the following:

    Satisfaction % =
    if(isfiltered(SentimentScore[Sentiment])="Negative",0,
    CALCULATE(count('SentimentScore'[MessageID]), FILTER('SentimentScore', 'SentimentScore'[Sentiment]<>"Negative"))
    /count('SentimentScore'[MessageID]))
     
    Thanks,
    Pragati