Forum Discussion

Philip_K6's avatar
Philip_K6
Regular Visitor
4 years ago
Solved

New Table with max Defects of each File

Hello everyone,

 

I am new to Power BI and DAX. I searched the forum for my problem but cant make it work.

I get my Data in the following Format. For each Coil there is a unique File that numbers the Defects in the order they occur and puts them in their Defect Category. There are about 20 different categories. In the example below i simplified it a bit. 

 

File Name              Order Number          Coil Number            Defect Category              Defect Number         
001-R1.csv001R1A1
001-R1.csv001R1A2
001-R1.csv001R1B3
001-R1.csv001R1A4
001-R2.csv001R2B1
001-R2.csv001R2A2
001-R2.csv001R2A3
001-R2.csv001R2B4
001-R2.csv001R2B5
002-R1.csv002R1A1
002-R1.csv002R1B2
002-R1.csv002R1A3
002-R2.csv002R2A1
002-R2.csv002R2A2
002-R2.csv002R2A3
002-R2.csv002R2A4
002-R2.csv002R2B5

 

Now i want to create a new table that lists the unique file name and the according number of Defects for each Category.

 

File Name (ID)         Defect Count Class "A"          Defect Count Class "B"
001-R131
001-R223
002-R121
002-R241


I already listed all the File Names with the DISTINCT Function 

File Name (ID) = DISTINCT(Table[File Name])

But i dont know how to count the number of defects for each class for the corresponding file name.

  • Hi Philip_K6 

    Thanks for your reply.

    >>  i want to create a new table that lists the unique file name and the according number of Defects for each Category.... I wanted to create a seperate table not a measure. ...I already listed all the File Names with the DISTINCT Function 

    Oh I got it. So we only need to perform distinct count on the basis of the file name list you created.

    Please try this, create the 2 columns in your list table,

    Defect Count A = COUNTX(FILTER('Table','Table'[File Name]=EARLIER('File Name (ID)'[File Name]) && 'Table'[Defect Category]="A" ),[Coil Number])
    Defect Count B = COUNTX(FILTER('Table','Table'[File Name]=EARLIER('File Name (ID)'[File Name]) && 'Table'[Defect Category]="B" ),[Coil Number])

    result

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

6 Replies

  • Philip_K6 , You should able to do that using a measure

     

    count(Table[Defect Number])

     

    And plot in visual with file name and class

  • Philip_K6's avatar
    Philip_K6
    Regular Visitor

    amitchandak thank you for your reply.
    What i eventually want to do is create a histogram that shows the number of coils that lie in a specific range of defects filtered by the Defect Class. Thats why I wanted to create a seperate table like I said in my post and not a measure. But if you think thats possible with a measure please tell me how.

  • v-xiaotang's avatar
    v-xiaotang
    Icon for Community Support rankCommunity Support

    Hi Philip_K6 

    Thanks for reaching out to us.

    >> expected result

    You can try this, 

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

  • Philip_K6's avatar
    Philip_K6
    Regular Visitor

    v-xiaotang thank you for your reply.

    Thats what I want to do but not as a visual. I want to reference that table again so I can group the seperate coils into ranges of defects. Something like this:

     

    • v-xiaotang's avatar
      v-xiaotang
      Icon for Community Support rankCommunity Support

      Hi Philip_K6 

      Thanks for your reply.

      >>  i want to create a new table that lists the unique file name and the according number of Defects for each Category.... I wanted to create a seperate table not a measure. ...I already listed all the File Names with the DISTINCT Function 

      Oh I got it. So we only need to perform distinct count on the basis of the file name list you created.

      Please try this, create the 2 columns in your list table,

      Defect Count A = COUNTX(FILTER('Table','Table'[File Name]=EARLIER('File Name (ID)'[File Name]) && 'Table'[Defect Category]="A" ),[Coil Number])
      Defect Count B = COUNTX(FILTER('Table','Table'[File Name]=EARLIER('File Name (ID)'[File Name]) && 'Table'[Defect Category]="B" ),[Coil Number])

      result

      Best Regards,

      Community Support Team _Tang

      If this post helps, please consider Accept it as the solution to help the other members find it more quickly.