Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Count depening date

Hi all,

 

I'm trying to extract the KPI of Quality service. To extrat the % i need to count the total orders for the last day in the dataset and count the incidents for the last day too. The question is, I don't know how to count dependig to date in a measure.

To have the last day in the dataset doing a MAX of the date is enought but I don't know how to implement that in a measure to have this condition. 

 

Thanks in advance

  • themistoklis's avatar
    themistoklis
    7 years ago

    Anonymous

     

    Maybe this formula is better:

     

    Incidenciasultimodia =
    VAR _Maxdate =
    MAX ( 'Dataset'[Transformed DATA] )
    RETURN
    CALCULATE (
    COUNT ( 'Dataset'[TIPO] );FILTER('Dataset';
    'Dataset'[Transformed DATA] = _Maxdate || LEFT( 'Dataset'[TIPO], 2) = "AB"
    ))

5 Replies

  • themistoklis's avatar
    themistoklis
    Community Champion

    Anonymous

     

    You can try the following measure:

     

    Measure =
    VAR _Maxdate =
        MAX ( 'Table'[Reference_Date] )
    RETURN
        CALCULATE (
            COUNT ( 'Table'[Order_ID] ),
            'Table'[Reference_Date] = _Maxdate
        )

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      themistoklis

       

      Thanks for your help it helps a lot :-)

       

      Related to that is it possible to add more conditions? for example now, i have the condition of the date but i want to add for example other like. Count if other column starts with AN por example.

       

       
      Incidenciasultimodia =
      VAR _Maxdate =
      MAX ( 'Dataset'[Transformed DATA] )
      RETURN
      CALCULATE (
      COUNT ( 'Dataset'[TIPO] );FILTER('Dataset';
      'Dataset'[Transformed DATA] = _Maxdate || 'Dataset'[TIPO] = "AN%"
      ))
       

       

      Now looks like this but is not working or showing an error

      • themistoklis's avatar
        themistoklis
        Community Champion

        Anonymous

         

        No problem at all.

         

        You can add other conditions as well.

        I think the percenrage symbol is causing the error.

         

        Change the formula to this one:

        Incidenciasultimodia =
        VAR _Maxdate =
        MAX ( 'Dataset'[Transformed DATA] )
        RETURN
        CALCULATE (
        COUNT ( 'Dataset'[TIPO] );FILTER('Dataset';
        'Dataset'[Transformed DATA] = _Maxdate || SEARCH("AN", 'Dataset'[TIPO],,0) <> 0
        ))

         

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi Anonymous,

     

    Could you please mark the proper answers as solutions?

     

     

    Best Regards,