Forum Discussion

MasterSonic's avatar
MasterSonic
Helper IV
3 years ago
Solved

Count if Filter help

Hi guys, the help I need is based on following logic:

I want to find all Test, where value is OK for Task and they have same Code.
As you see In the table
Code is repetitve(result of unpivoting) and Task = Design ,  Code = 1, Test  = Wrong and Value  = OK (FOR 2 ROWS)
Can you help me with any measuremt or column who could catch that kind of scenarios please

CodeTaskTestValue
1DesignWrongOK
2Check if blankInnacurate NO
3Name CorrectOK
4CodeDismissNO
1DesignWrongOK
2Check if blankInnacurate OK
3Name CorrectNO
4CodeDismissOK

 

 

Output should be in table visual shown as below as I have only one distinct value.

TaskCreated Column/Measuremnt  DISTINCT COUNT 
Design                                    1
  • Hi MasterSonic 

    Thanks for reaching out to us.

    please try this

    sample data

    isduplicate = 
    var _count=COUNTROWS('Table')
    return if(_count>1,MIN('Table'[Code]))
    Measure = 
    var _t= FILTER('Table',[isduplicate]<>BLANK())
    return COUNTX(DISTINCT(_t),[Code])

    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.

10 Replies

    • MasterSonic's avatar
      MasterSonic
      Helper IV

      Hi,

      sorry I did not mentioned that there are few more columns in this table with veriaty of values

       

      I think COUNTROWS ( DISTINCT ( TableName ) ) will not do the job.

      Can COUNTROWS ( DISTINCT ( TableName ) )  be specificed just to these 4 columns i mentioned in my 1st post.?

       

      • tamerj1's avatar
        tamerj1
        Community Champion

        MasterSonic 

        yes of course. You select the required columns

        COUNTROWS ( DISTINCT ( SELECTCOLUMNS ( TableName, "@Code", [Code], "@Teast", [Test], "@Value", [Value] ) ) )

  • Nah, that does not work for me. 
    And actually very first solution you sent gives me this : <ccon>A circular dependency was detected: Table[Column].</ccon>

    I will rephrase my question maybe as I can't  figure out how to solve it.

    CodeTaskTestValue
    100DesignWrongOK
    200Check if blankInnacurate NO
    300Name CorrectOK
    400CodeDismissNO
    100DesignWrongOK
    200Check if blankInnacurate OK
    300Name CorrectNO
    400CodeDismissOK



    What I would like to get as visual :

    TestCreated Column/Measuremnt  
    Innacurate    here will be blank as none of Code,Task,Value are same in rows  (Value column is different)                         
    Wronghere is 1 as for all Code rows have value 100 and same Task (Desing) and Value ( OK).

    Correcthere will be blank as none of Code,Task,Value are same in rows 
    Dismisshere will be blank as none of Code,Task,Value are same in rows 
    • tamerj1's avatar
      tamerj1
      Community Champion

      MasterSonic 

      IF ( COUNTROWS ( DISTINCT ( TableName ) ) <> COUNTROWS ( TableName ), 1 )

      • MasterSonic's avatar
        MasterSonic
        Helper IV

        <ccon>A circular dependency was detected: Table[Column].</ccon>

        Maybe its becouse I have many custom columns here created in PowerQuery

  • I try to sort it other way - can you help with this:

    I have created measurement:
    Distinct Count Attributes = CALCULATE (DISTINCTCOUNT(CleanTable[Task]))

    this one five me count of 15
     
    I have added SumColumn in power query which summarize columns.

     
    I would like to get measurement: (deduction)
    Distinct Count Attributes - SumColumn

     

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

    Hi MasterSonic 

    Thanks for reaching out to us.

    please try this

    sample data

    isduplicate = 
    var _count=COUNTROWS('Table')
    return if(_count>1,MIN('Table'[Code]))
    Measure = 
    var _t= FILTER('Table',[isduplicate]<>BLANK())
    return COUNTX(DISTINCT(_t),[Code])

    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.