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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
MasterSonic
Helper IV
Helper IV

Divide 2 columns and count per category beforehand

Hello,

I have a Table where Code is unique.

 

I would like to get a division of stock by count of Group values please 

 

Eg.

Stock = 40, count of Jeans=2 so 40/2=20

 

 

CodeGroupstockResult I would like to get
101Jeans 4020
102Jeans 4020
103Suits6020
104Suits 6020
105Suits 6020
106Shoes 10

10

 

Thank You

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @MasterSonic 

please try

CalculatedColumn =
DIVIDE (
'Table'[Stock],
COUNTROWS ( CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Group] ) ) )
)

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

you may also try

Column=

VAR CurrentGroup = TableName[Group] 

VAR CurrentStockType = TableName[Stock] 

VAR CurrentGroup =

COUNTROWS(

     FILTER(

        TableName,

 

        TableName[Group] = CurrentStockType

     )

 

)

RETURN

DIVIDE ( CurrentGroup, CurrentGroup )

Hi there,

 

I did try your solution and have an issues.

 

Shouldn't be second

VAR CurrentGroup

Different name like CurrentGroup2 ?

 

I have error about that.

 

 

I did change it , but still showing that can not transform values from Group of type text into number 

 

tamerj1
Super User
Super User

Hi @MasterSonic 

please try

CalculatedColumn =
DIVIDE (
'Table'[Stock],
COUNTROWS ( CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Group] ) ) )
)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.