Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
harshagraj
Post Partisan
Post Partisan

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 

1 ACCEPTED SOLUTION

@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")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@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")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

 

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.

harshagraj_0-1657538834904.png

 

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" )

 

@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")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak the above calculations work perfectly but i have an slicer Region Code.
When i modify like this 
var _cnt = countx(filter(Table, [PRJ] =earlier([PRJ]) && [Segment] =71&&[Regioncode]=selectedvalue(regoincode)),[PRJ]) it doesnt work but when i modify like this it works var _cnt = countx(filter(Table, [PRJ] =earlier([PRJ]) && [Segment] =71&&[Regioncode]="0401",[PRJ])
could you please help me on this?

Hi @amitchandak please help me to adjust the calculation so that if we select region code as 0401 then the calcuation should happen accordingly. Currently if i select 0401 it doesnt work.I dont want to hardcode

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.