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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Ilse_ScpDt
Helper I
Helper I

Count rows depending on other row values by group

I would like to count rows (number of clauses) with following logic:

- if within one organization a clause number ending on a zero is present the other clauses with the same starting number shouldn't be counted.

 

So for organization A clause number 6.0 is present and therefore 6.1 and 6.2 shouldn't be counted. Clause 6.0 itself is always counted. The total number of clauses for this organization is 3.

 

OrganizationClauseCount
A2.1Yes
A6.0Yes
A6.1No
A6.2No
A7.1Yes
B5.2Yes
B7.0Yes
B7.1No

 

I would like to create the third column above, so I can just use a filter on each page. Of course it is also possible to create a general measure and place it in a table with Organization, but I would also like to visualize the total number of clauses (e.g. by country) with the above logic. 

 

How could I create this calculated column?

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Ilse_ScpDt 

 

Based on your description, i created data to reproduce your scenario. The pbix file is attached in the end.

Table:

e1.png

 

You may create a calculated column and a measure as below.

Calculated column:

Flag Column = 
var _min = 
MINX(
    FILTER(
        'Table',
        [Organization]=EARLIER('Table'[Organization])&&
        ROUNDDOWN([Clause],0)=ROUNDDOWN(EARLIER('Table'[Clause]),0)
    ),
    [Clause]
)
return
IF(
    _min=ROUNDDOWN([Clause],0),
    IF(
        [Clause]=_min,
        "Yes",
        "No"
    ),
    "Yes"
)

Measure:

Count Measure = 
COUNTROWS(
    FILTER(
        ALLSELECTED('Table'),
        [Flag Column]="Yes"
    )
)

 

Result:

e2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Ilse_ScpDt 

 

Based on your description, i created data to reproduce your scenario. The pbix file is attached in the end.

Table:

e1.png

 

You may create a calculated column and a measure as below.

Calculated column:

Flag Column = 
var _min = 
MINX(
    FILTER(
        'Table',
        [Organization]=EARLIER('Table'[Organization])&&
        ROUNDDOWN([Clause],0)=ROUNDDOWN(EARLIER('Table'[Clause]),0)
    ),
    [Clause]
)
return
IF(
    _min=ROUNDDOWN([Clause],0),
    IF(
        [Clause]=_min,
        "Yes",
        "No"
    ),
    "Yes"
)

Measure:

Count Measure = 
COUNTROWS(
    FILTER(
        ALLSELECTED('Table'),
        [Flag Column]="Yes"
    )
)

 

Result:

e2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-alq-msft 

Thanks a lot! This is working.

Ilse_ScpDt
Helper I
Helper I

@amitchandak Thanks for your reply, this is already in the right direction but still needs some alterations. 

 

For one of the organizations this is the result:

 

1.0Yes
1.1No
2.2Yes
4.1Yes
6.1Yes
6.3No
7.6No
7.7No

 

So clause 1.1 is not counted because of clause 1.0, that's correct. This logic needs to be true only in case of a clause zero.

Now also 6.3 is not counted because there is a lower clause number (6.1), but they should both be counted because there is no clause 6.0.

Why both 7.6 and 7.7 aren't counted I am not sure.

amitchandak
Super User
Super User

@Ilse_ScpDt , Create a new column like

 


new column =
var _min = minx(filter(Table, [Organization] =earlier([Organization]) , rounddown([Clause],0) = rounddown(earlier([Clause]),0)),[Clause])
return
if([Clause] =_min, "Yes", "No")

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.