Forum Discussion

Shree_185's avatar
Shree_185
Helper I
4 years ago
Solved

Need help in calculation

Hi everyone,

 

I m trying to calculate the Final Output column

 

1. If the same ID has multiple only COW values, print COW

2. If the same ID has multiple only Revisit values, print Revisit

3. If the same ID has a combination of COW and Revisit print Revisit

 

 

IDValuesFinal Output
S000947-A-003COWRevisit
S000947-A-003RevisitRevisit
S000960-A-003COWCOW
S000960-A-003COWCOW
S000982-A-003RevisitRevisit
S000982-A-003RevisitRevisit
S001901-A-001RevisitRevisit
S001901-A-001COWRevisit
S001901-A-001COWRevisit
S001901-A-001RevisitRevisit

 

  • rsbin's avatar
    rsbin
    4 years ago

    Shree_185 ,

    In the Return part of the Measure, I simply changed the condition to read:

    COWCount >=1.  It appears this is what you need.

    Please see your pbix attached.

     

12 Replies

  • rsbin's avatar
    rsbin
    Community Champion

    Shree_185 ,

    There are probably a few different ways this can be done.  Here is my suggestion:

    FinalOutput = 
    VAR _ID = [ID]
    VAR _RowCount = CALCULATE( COUNTROWS( Shree ), FILTER( YourTable, YourTable[ID] = _ID ))
    VAR _COWCount = CALCULATE( COUNTROWS( Shree ), FILTER( YourTable, YourTable[ID] = _ID  && [Values] = "COW" )) + 0
    RETURN
        IF( _RowCount = _COWCount, "COW", "Revisit" )

    Basically I am calculating all rows for each ID.  Then calculating COW Rows for each ID.  If they are the same, then "COW", else "Revisit"

    IDValuesFinalOutput

    S000947-A-003 COW Revisit
    S000947-A-003 Revisit Revisit
    S000960-A-003 COW COW
    S000960-A-003 COW COW
    S000982-A-003 Revisit Revisit
    S000982-A-003 Revisit Revisit
    S001901-A-001 Revisit Revisit
    S001901-A-001 COW Revisit
    S001901-A-001 COW Revisit
    S001901-A-001 Revisit

    Revisit

     

    Hope this gets you what you are looking for.

    Regards,

    • Shree_185's avatar
      Shree_185
      Helper I

      rsbin Thank you, Actually, I want

      1. ID-wise, all cow then cow

      2. ID-wise, all Revisit then Revisit

      3 else Revisit

      • rsbin's avatar
        rsbin
        Community Champion

        Shree_185 ,

        Good Morning.  This is the logic I have provided you.

        Your conditions 2 and 3 are the same.  

        If any of the rows are not "COW" then the value is "Revisit".