Forum Discussion

harshagraj's avatar
harshagraj
Post Partisan
4 years ago
Solved

Issue in countrows

Hi all i have a table where is have to consider a "Partnrer" project if it is already an "Owner". Please see the data below

If Segment is 71 then it is Owner else Partner

PRJSegmentOwner/Partnrer
A71Owner
A1Partner
A2Partner
B3Partner
C71Owner
C13Partner
D71Owner

 

I need to consider only A,C because its Partner has owner.

I created countrows(Filter(table,earlier(prj)=prj) but not working properly.
amitchandak 

  • harshagraj , Try if this can help

     


    new column =
    var _cnt = countx(filter(Table, [PRJ] =earlier([PRJ]) && [Segment] =71),[PRJ])
    var _cnt1 = countx(filter(Table, [PRJ] =earlier([Owner/Partnrer]) && [Segment] = "Partner"),[PRJ])
    return
    if(not(isblank(_cnt)) && not(isblank(_cnt1)) , "Owner", "Other")

5 Replies

  • harshagraj , Try a new column like

     


    new column =
    var _cnt = countx(filter(Table, [PRJ] =earlier([PRJ]) && [Segment] =71),[PRJ])
    return
    if(isblank(_cnt),[Segment], "Owner")

    • harshagraj's avatar
      harshagraj
      Post Partisan

       

      Hi amitchandak thanks for the reply but it is not giving me desired solution, in the below ss highlighted ones doesnt have a partner at all.

       

      Partner =
      VAR cnt =
      COUNTX (
      FILTER (
      'OS Sales_Project_WonLost_VW',
      'OS Sales_Project_WonLost_VW'[SF_Number]
      = EARLIER ( 'OS Sales_Project_WonLost_VW'[SF_Number] )
      && 'OS Sales_Project_WonLost_VW'[Segment_code] = "0071"
      ),
      'OS Sales_Project_WonLost_VW'[SF_Number]
      )
      RETURN
      IF ( ISBLANK ( cnt ), 'OS Sales_Project_WonLost_VW'[Segment_code], "Owner" )

       

      • amitchandak's avatar
        amitchandak
        Super User

        harshagraj , Try if this can help

         


        new column =
        var _cnt = countx(filter(Table, [PRJ] =earlier([PRJ]) && [Segment] =71),[PRJ])
        var _cnt1 = countx(filter(Table, [PRJ] =earlier([Owner/Partnrer]) && [Segment] = "Partner"),[PRJ])
        return
        if(not(isblank(_cnt)) && not(isblank(_cnt1)) , "Owner", "Other")