Forum Discussion

X19203659's avatar
X19203659
Helper I
1 year ago
Solved

Measure Dax Count if Over

Hi Comunity

 

I need your help. 

What I am trying to achieve is to count, via a measure, the number of training "Never completed" by Name to generate a Databar in this table visual. 

 

The first 4 columns comes from the "employee" table the 2 last columns come from the "Training" table. These 2 above table are link via the employee ID. 

 

table visual

 

employee table (employee ID= "Driver Id")

 

 

training table (employee ID= "dcdriverid")

 

many thanks kin adavance for your support

 

kind regrads

 

 

  • saud968's avatar
    saud968
    1 year ago

    Try this

    Create a Measure:
    Go to the “Modeling” tab and select “New Measure”.
    Use the following DAX formula to create the measure:
    Count Never Completed =
    CALCULATE(
    COUNTROWS(Training),
    Training[status] = "never completed"
    )


    Create a Calculated Column:
    In the “Training” table, create a new calculated column to count the “Never completed” trainings for each employee:
    Count Over =
    CALCULATE(
    COUNTROWS(Training),
    Training[status] = "never completed",
    ALLEXCEPT(Training, Training[id employee])
    )


    Add the Measure to Your Table Visual:
    Add the Count Over column to your table visual along with the other columns from the “employee” and “Training” tables.

    This will give you the desired result where the “Count Over” column shows the number of “Never completed” trainings for each employee.

    Here’s how your table visual should look:

    Table

    id name training status Count Over
    1 thomas training 2 never completed 1
    2 charles training 2 never completed 2
    2 charles training 4 never completed 2

    Best Regards
    Saud Ansari
    If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

7 Replies

  • Confirm that there is a relationship between the Employee table (Driver Id) and the Training table (dcdriverid).

    Create the Measure:

    NeverCompletedCount = 
    CALCULATE(
    COUNTROWS('Training'),
    'Training'[training Status] = "Never completed"
    )

    Add this measure to your table visual that displays employee details along with their training information.

    Enable Data bars to visually represent the count.

    If this helped, a Kudos 👍 or Solution mark would be great! 🎉
    Cheers,
    Kedar
    Connect on LinkedIn

    • X192036598's avatar
      X192036598
      Frequent Visitor

      Hi Kedar,

       

      thank you for you quick answer!

       

      yes, there is a relationship between  the 2 tables employee & training (1:*).

       

      my initial question was more about the count over the table visual if the the employee "never completed" the training.

       

      kind regads

      • saud968's avatar
        saud968
        Memorable Member

        Not sure what you want to achieve the measure from Kedar_Pande should work properly. if you share some example it will become easier to help

  • X192036598's avatar
    X192036598
    Frequent Visitor

    thank you Saud968.

    this below solution was perfect.

     

    Create a Calculated Column:
    In the “Training” table, create a new calculated column to count the “Never completed” trainings for each employee:
    Count Over =
    CALCULATE(
    COUNTROWS(Training),
    Training[status] = "never completed",
    ALLEXCEPT(Training, Training[id employee])
    )

     

    kind regards

    • saud968's avatar
      saud968
      Memorable Member

      Glad that it helped, please Accept it as a Solution. 


      Best Regards
      Saud Ansari
      If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

  • X192036598's avatar
    X192036598
    Frequent Visitor

    Hi,

     

    here is an example.

     

    employee & training are linked by "id" & "id employee"

     

    employee table

     

    idname
    1thomas
    2charles

     

    training table

     

    id employeetrainingstatus
    1training 1completed
    1training 2never completed
    2training 1completed
    2training 2never completed
    2training 3completed
    2training 4never completed

     

    Result expected column called "Count over"

    This column is calculated the number of ID  where the status is "Never completed"

    id "2" appear twice because he never completed the training 2&4. Therefore, the count over column should have 2

     

    result expected (within a Table visual)

    idnametrainingstatusCount Over
    1thomastraining 2never completed1
    2charlestraining 2never completed2
    2charlestraining 4never completed2

     

    Hopefully it clarify what i would like to achieve.

    Thank you in advance.

    • saud968's avatar
      saud968
      Memorable Member

      Try this

      Create a Measure:
      Go to the “Modeling” tab and select “New Measure”.
      Use the following DAX formula to create the measure:
      Count Never Completed =
      CALCULATE(
      COUNTROWS(Training),
      Training[status] = "never completed"
      )


      Create a Calculated Column:
      In the “Training” table, create a new calculated column to count the “Never completed” trainings for each employee:
      Count Over =
      CALCULATE(
      COUNTROWS(Training),
      Training[status] = "never completed",
      ALLEXCEPT(Training, Training[id employee])
      )


      Add the Measure to Your Table Visual:
      Add the Count Over column to your table visual along with the other columns from the “employee” and “Training” tables.

      This will give you the desired result where the “Count Over” column shows the number of “Never completed” trainings for each employee.

      Here’s how your table visual should look:

      Table

      id name training status Count Over
      1 thomas training 2 never completed 1
      2 charles training 2 never completed 2
      2 charles training 4 never completed 2

      Best Regards
      Saud Ansari
      If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!