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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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