Forum Discussion

Michael92's avatar
Michael92
Frequent Visitor
4 years ago
Solved

Calculate today cases

Hello all,

 

I would like to count the number of cases for today and if there is an empty value, write zero.

I have already created these measures, but how to connect them together and create one measure?

 

Count_today = CALCULATE (DISTINCTCOUNT ( 'case'[id_case] ), 'case'[date] = TODAY ())
Count_zero_value = if(isblank(DISTINCTCOUNT(case[id_case])),0,DISTINCTCOUNT(case[id_case]))
 
Thank you
Michael
 
 
  • OK, now it works. Only a few parentheses needed to be added.

     

    MyMeasure =
    var Count_today = CALCULATE (DISTINCTCOUNT ( 'case'[id_case] ), 'case'[date] = TODAY ())


    return
    IF(
    ISBLANK(Count_today),0,(Count_today)
    )

     

    Thank you 😊

3 Replies

  • Migasuke's avatar
    Migasuke
    Icon for Memorable Member rankMemorable Member

    Hi Michael92 ,

    I don't think you need the second measure if I understand correctly.

    Try following:

    MyMeasure =
    var Count_today = CALCULATE (DISTINCTCOUNT ( 'case'[id_case] ), 'case'[date] = TODAY ())

    return
    IF(
    ISBLANK(Count_today,0,Count_today)
    )

    • Michael92's avatar
      Michael92
      Frequent Visitor

      The syntax for 'returnif' is incorrect 🙄

      Too many arguments were passed to the ISBLANK function. The maximum argument count for the function is 1.

      • Michael92's avatar
        Michael92
        Frequent Visitor

        OK, now it works. Only a few parentheses needed to be added.

         

        MyMeasure =
        var Count_today = CALCULATE (DISTINCTCOUNT ( 'case'[id_case] ), 'case'[date] = TODAY ())


        return
        IF(
        ISBLANK(Count_today),0,(Count_today)
        )

         

        Thank you 😊