Forum Discussion

spandy34's avatar
spandy34
Responsive Resident
2 years ago
Solved

Average - Distinct Count

I have the matrix below  which has a Distinct Count of field [Claim Ref] within the Table named INS_Main Claim Data by Calendar Month.

 

I would like a column at the end after March column which has the Average for each year for each Class of Business

 

How would I write the DAX for this please?

 

 

 

amitchandak tamerj1 danextian goncalogeraldes Anonymous Anonymous Uzi2019 

  • Hi

    I resolved this by

    • Creating a column in the INS_Main Claim Data table and called it [AverageCountColumn] which placed a number 1 in each row of the table
    • Within the same table I created a field called Month_Year which was the Notification Date in the format of

     Notification Month Year = FORMAT([NotificationDate]," mmm yyyy")

    • I created a measure which calculated a distinctcount of the notification month year:-

     

    Z_Count of Month_Year = (DISTINCTCOUNT('INS_Main Claim Data'[Notification Month Year]))

     

    • I created a measure of the count of the total claim refs:-

     

    z_Generic_No of Claims Distinct = DISTINCTCOUNT('INS_Main Claim Data'[ClaimRef])

     

    • I created an average measure

     

    z_1Average = DIVIDE([z_Generic_No of Claims Distinct],[Z_Count of Month_Year])

     

    • I then created the matrix

     

     

     

    • I created the matrix and hid all the average fields apart from the average total

     

     

     

    Using a slicer I can now create the a table below which calculates the average based on the number of distinct month year values.  I am sure there is a cleverer way to do this using DAX but with my limited knowledge this solution has worked.

     

14 Replies

  • no need for DAX.  Specify the value aggregation as Average, and enable Column totals.

    • spandy34's avatar
      spandy34
      Responsive Resident

      Hi  When you say specify the value aggregation as Average and enable Columns, Im a bit unsure how to do it.  Please can you suggest how I change the format below.  Many thanks

      The Matrix is made up of

       

      Rows  -               Class of Business Code

                                      Year

      Columns           CalMonth

      Values                Count of Claims

       

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, spandy34 

    Here, thanks for lbendlin reply. You can refer to his reply, and if it didn't work, you can share the pbix file without sensitive data, or share the datasheet, measure, etc. that will enable you to simulate your matrix.

    Best Regards,
    Yang
    Community Support Team

    • spandy34's avatar
      spandy34
      Responsive Resident

      Hi  

      Here is the data table linked to a calendar table by Dateid_NotificationDate

       

      Claim RefClassOfBusinessCodeNotificationDateDateid_NotificationDate
      7313IN23/11/199919991123
      7395IN03/04/200020000403
      13029IN15/12/200420041215
      12922IN24/10/200420041024
      12921IN23/10/200420041023
      25967EL20/03/201220120320
      25010EL10/05/201120110510
      25009EL10/05/201120110510
      25008EL10/05/201120110510
      25007EL10/05/201120110510
      25006EL10/05/201120110510
      24897EL04/04/201120110404
      24877EL25/03/201120110325
      24862EL22/03/201120110322
      24844EL21/03/201120110321
      24843EL21/03/201120110321
      24842EL21/03/201120110321
      24791EL08/03/201120110308
      24790EL08/03/201120110308
      24723EL15/02/201120110215
      24599EL21/01/201120110121
      24598EL21/01/201120110121
      24511ML23/12/201020101223
      24510ML23/12/201020101223
      24477ML14/12/201020101214
      24476ML14/12/201020101214
      24474ML14/12/201020101214
      24473ML14/12/201020101214
      24472ML14/12/201020101214
      24471ML14/12/201020101214
      24350ML10/11/201020101110
      24284ML26/10/201020101026
      24249ML18/10/201020101018
      24191ML28/09/201020100928
      24190ML28/09/201020100928
      24177ML24/09/201020100924
      24176ML24/09/201020100924
      24125ML15/09/201020100915
      23957ML21/07/201020100721
      23956ML21/07/201020100721
      23883ML07/07/201020100707
      23879ML07/07/201020100707
      23878ML07/07/201020100707
      23876ML07/07/201020100707
      23875ML07/07/201020100707
      23791ML22/06/201020100622
      23790ML22/06/201020100622
      10942MV03/02/200320030203
      10122MV18/09/200220020918
      9870MV23/07/200220020723
      19447MV22/04/200820080422
      18774MV28/01/200820080128
      18057OT19/09/200720070919
      18358OT15/11/200720071115
      17210OT12/07/200720070712
      17282OT23/07/200720070723
      26217OT29/05/201220120529
      26216PL29/05/201220120529
      26215PL29/05/201220120529
      26214PL29/05/201220120529
      26213PL29/05/201220120529
      26212PL29/05/201220120529
      26295PL29/06/201220120629
      26294PR29/06/201220120629
      26293PR29/06/201220120629
      26292PR29/06/201220120629
      26273PR22/06/201220120622
    • spandy34's avatar
      spandy34
      Responsive Resident

      Calendar Table

       

      DateCalMonthCalYearDateid
      03/07/1899Jul189918990703
      08/07/1901Jul190119010708
      07/07/1902Jul190219020707
      06/07/1903Jul190319030706
      04/07/1904Jul190419040704
      03/07/1905Jul190519050703
      08/07/1907Jul190719070708
      06/07/1908Jul190819080706
      05/07/1909Jul190919090705
      04/07/1910Jul191019100704
      03/07/1911Jul191119110703
      08/07/1912Jul191219120708
      07/07/1913Jul191319130707
      06/07/1914Jul191419140706
      05/07/1915Jul191519150705