Forum Discussion

romovaro's avatar
romovaro
Responsive Resident
4 years ago
Solved

Custom Dax Calculating columns

 

 I need to create the following custom measures but i am having issues with the formula:
 
Below the table with the columns I need.
Task column has a lot of different and I only need to count the ones "Pre Engagement Process" and "IPM HandOff".
 
CLIENT_NAMECIDTASKTASK_STATUSSCHEDULED
Customer A380206Pre Engagement ProcessClosed18-AUG-21  
Customer A380206IPM HandOffClosed 
Customer B380208Pre Engagement ProcessClosed07-jul-21
Customer B380208IPM HandOffClosed20-jul-21
Customer C380209Pre Engagement ProcessReceived 
Customer D380210IPM HandOffClosed10-AUG-21  
Customer D380210Pre Engagement ProcessClosed31-jul-21

 

Total Tasks Pre engagement Team. (Formula that calculates all the task with task: "Pre Engagement Process" and Task_Status "Closed & Received" and all the task : "IPM HandOff" with Task_status "Received")

 

Total Tasks Pre-Engagement Team = CALCULATE(COUNTROWS(CELERGO_12062021V1),Filter(CELERGO_12062021V1,CELERGO_12062021V1[TASK_STATUS] ="Received" && CELERGO_12062021V1[TASK] IN { "Pre Engagement Process", "IPM HandOff" }))   
(I just need to add in the formula that I also want "Pre Engagement Process = Closed). Tried different options but...

 

 Total Tasks Pre engagement Team Closed. (Formula that calculates all the task with task: "IPM HandOff" and Task_Status "Closed" and have a Scheduled Date

 

Total Tasks Pre-Engagement Team Closed = CALCULATE(COUNTROWS(CELERGO_12062021V1),Filter(CELERGO_12062021V1,CELERGO_12062021V1[TASK] ="IPM HandOff" && CELERGO_12062021V1[TASK_STATUS]="Closed"))
(I just need to add in the formula that I want to add the count  with a date in the Schedule column)
 
 
Thanks
  • Hi romovaro 

     

    You can use || (OR) in the measure. 

    Total Tasks Pre-Engagement Team = 
    CALCULATE (
        COUNTROWS ( CELERGO_12062021V1 ),
        FILTER (
            CELERGO_12062021V1,
            ( CELERGO_12062021V1[TASK_STATUS] IN { "Received", "Closed" } && CELERGO_12062021V1[TASK] = "Pre Engagement Process" )
                || ( CELERGO_12062021V1[TASK_STATUS] = "Received" && CELERGO_12062021V1[TASK] = "IPM HandOff" )
        )
    )

     

    And use NOT(ISBLANK()) to determine whether a row in the column has a value. 

    Total Tasks Pre-Engagement Team Closed = 
    CALCULATE (
        COUNTROWS ( CELERGO_12062021V1 ),
        FILTER (
            CELERGO_12062021V1,
            CELERGO_12062021V1[TASK] = "IPM HandOff"
                && CELERGO_12062021V1[TASK_STATUS] = "Closed"
                && NOT ( ISBLANK ( CELERGO_12062021V1[SCHEDULED] ) )
        )
    )

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.

  • Hi romovaro 

     

    You can tweak the current measures. 

    Total Tasks Pre-Engagement Team =
    CALCULATE (
        COUNTROWS ( CELERGO_12062021V1 ),
        FILTER (
            CELERGO_12062021V1,
            ( CELERGO_12062021V1[TASK_STATUS] IN { "Received", "Closed" }
                && CELERGO_12062021V1[TASK] = "Pre Engagement Process" )
        )
    )
    
    Total Tasks Pre-Engagement Team Closed =
    CALCULATE (
        COUNTROWS ( CELERGO_12062021V1 ),
        FILTER (
            CELERGO_12062021V1,
            CELERGO_12062021V1[TASK] = "IPM HandOff"
                && CELERGO_12062021V1[TASK_STATUS] = "Closed"
        )
    )
    

    Then create a third measure

    Current Workload = [Total Tasks Pre-Engagement Team] - [Total Tasks Pre-Engagement Team Closed]

     

    Best regards,

    Jing

  • Hi romovaro 

     

    You can use this measure as a filter field in the table visual.

    Flag =
    VAR __clientsPEP =
        SELECTCOLUMNS (
            FILTER (
                ALL ( CELERGO_12062021V1 ),
                ( CELERGO_12062021V1[TASK_STATUS]
                    IN { "Received", "Closed" }
                    && CELERGO_12062021V1[TASK] = "Pre Engagement Process" )
            ),
            "Client", CELERGO_12062021V1[CLIENT_NAME]
        )
    VAR __clientIH =
        SELECTCOLUMNS (
            FILTER (
                ALL ( CELERGO_12062021V1 ),
                CELERGO_12062021V1[TASK] = "IPM HandOff"
                    && CELERGO_12062021V1[TASK_STATUS] = "Closed"
            ),
            "Client", CELERGO_12062021V1[CLIENT_NAME]
        )
    VAR __current = EXCEPT ( __clientsPEP, __clientIH )
    RETURN
        IF ( SELECTEDVALUE ( CELERGO_12062021V1[CLIENT_NAME] ) IN __current, 1 )
    

     

    Best Regards,

    Jing

10 Replies

  • Not exactly clear what your boolean statement would look like but your can use "IN"  as stand-in for "OR"

     

    CALCULATE(COUNTROWS(CELERGO_12062021V1),CELERGO_12062021V1[TASK_STATUS] IN {"Received","Closed"},  CELERGO_12062021V1[TASK] IN { "Pre Engagement Process", "IPM HandOff" })   

    , as you already did for part of it. 

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

    Hi romovaro 

     

    You can use || (OR) in the measure. 

    Total Tasks Pre-Engagement Team = 
    CALCULATE (
        COUNTROWS ( CELERGO_12062021V1 ),
        FILTER (
            CELERGO_12062021V1,
            ( CELERGO_12062021V1[TASK_STATUS] IN { "Received", "Closed" } && CELERGO_12062021V1[TASK] = "Pre Engagement Process" )
                || ( CELERGO_12062021V1[TASK_STATUS] = "Received" && CELERGO_12062021V1[TASK] = "IPM HandOff" )
        )
    )

     

    And use NOT(ISBLANK()) to determine whether a row in the column has a value. 

    Total Tasks Pre-Engagement Team Closed = 
    CALCULATE (
        COUNTROWS ( CELERGO_12062021V1 ),
        FILTER (
            CELERGO_12062021V1,
            CELERGO_12062021V1[TASK] = "IPM HandOff"
                && CELERGO_12062021V1[TASK_STATUS] = "Closed"
                && NOT ( ISBLANK ( CELERGO_12062021V1[SCHEDULED] ) )
        )
    )

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.

    • romovaro's avatar
      romovaro
      Responsive Resident

       

      it seems I would need the same formula but instead of using the "OR"..I need Minus IPM handOff Closed

       

      I need to provide the total of "Pre Engagement Process - Closed and recevied) like your formula does...

       

      MINUS

       

      the IPM HandOff Tasks with status closed. (instead of Received)

       

      How could I add the minus in the formula? Thanks

      • lbendlin's avatar
        lbendlin
        Super User

        Your formula already does that.  If you filter by a particular value A then you don't need to include another condition to exclude value B - that is already implicit.

         

        AND  = all conditions apply

        OR = any one condition is sufficient

         

        By the way your "minus"  would translate to AND NOT  (if it were needed)