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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Count rows by subgroup depending on other rows

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-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can create a calculated column as below:

Count = 
VAR _curclause='Clause'[Clause]
VAR _mvalue=CALCULATE(MIN('Clause'[Clause]),FILTER(ALL('Clause'),'Clause'[Organization]=EARLIER('Clause'[Organization])
&&LEFT('Clause'[Clause], IF(SEARCH(".",'Clause'[Clause],1,0)=0,LEN('Clause'[Clause]),SEARCH(".",'Clause'[Clause],1,0)-1))=LEFT(_curclause, IF(SEARCH(".",_curclause,1,0)=0,LEN(_curclause),SEARCH(".",_curclause,1,0)-1))))
RETURN IF(_curclause=_mvalue,1,0)

yingyinr_0-1616740173544.png

Best Regards

Community Support Team _ Rena
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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can create a calculated column as below:

Count = 
VAR _curclause='Clause'[Clause]
VAR _mvalue=CALCULATE(MIN('Clause'[Clause]),FILTER(ALL('Clause'),'Clause'[Organization]=EARLIER('Clause'[Organization])
&&LEFT('Clause'[Clause], IF(SEARCH(".",'Clause'[Clause],1,0)=0,LEN('Clause'[Clause]),SEARCH(".",'Clause'[Clause],1,0)-1))=LEFT(_curclause, IF(SEARCH(".",_curclause,1,0)=0,LEN(_curclause),SEARCH(".",_curclause,1,0)-1))))
RETURN IF(_curclause=_mvalue,1,0)

yingyinr_0-1616740173544.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , Try 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")

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.