Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Is a row valid or not?

Hi - I have a CRM data dump with a challenge. For every CALL_NAME there can be multiple rows with a row for each PRODUCT_NAME that was discussed. EG

 

CALL_NAMEPRODUCT_NAME
ACB123PR1
ACB123PR2
ACB123PR3
CAD456PR2
CAD456PR7

 

I need to classify each row as valid or not. They are valid if the CALL_NAME = PR1. Therefore if CALL_NAME has PR1 listed against it somewhere, return VALID, if not NOT VALID.

 

CALL_NAMEPRODUCT_NAMEVALIDITY
ACB123PR1VALID
ACB123PR2VALID
ACB123PR3VALID
CAD456PR2NOT VALID
CAD456PR7NOT VALID

 

Any ideas for DAX on the 'VALIDITY' column?

 

  • Hi,

    This calculated column formula works

    =if(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[CALL_NAME]=EARLIER(Data[CALL_NAME])&&Data[PRODUCT_NAME]="PR1"))>=1,"Valid","Not valid")

    Hope this helps.

4 Replies

  • Hi Anonymous ,

     

    If you want to do this in the Power Query side, this is a simple Conditional Column.  If you want to use DAX, then it will probably be something like this:

    Validity = If(table[Product_Name] = "PR1", "Valid","Not Valid")

     

    I can't test this right now, the PR1 might have no quotes or single quotes around it for this to work.

     

    I would appreciate Kudos if my response was helpful. I would also appreciate it if you would Mark this As a Solution if it solved the problem. Thanks!
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks - I need 'Valid' to appear even where PR1 isn't (but the call name that has used PR1 is)...not sure this will do that

      • collinq's avatar
        collinq
        Icon for Super User rankSuper User

        Hey Anonymous ,

         

        If I am understanding what you are asking - you are saying that WHENEVER a call name had a product name at any point that was a "PR1" then it is valid?  If that is true, then I would probably do a filter in the Query Editor (may have to duplicate the original table) for the PR1 value and add a column for the then link that to the original table in the relationships (or add it as a column in a merge in the Query Editor).

         

        If you really want to get a DAX way to do this and not use Query Editor then please mark this as solved and create your request in the DAX forum

         

        I would appreciate Kudos if my response was helpful. I would also appreciate it if you would Mark this As a Solution if it solved the problem. Thanks!
  • Hi,

    This calculated column formula works

    =if(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[CALL_NAME]=EARLIER(Data[CALL_NAME])&&Data[PRODUCT_NAME]="PR1"))>=1,"Valid","Not valid")

    Hope this helps.