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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
dwalters
Frequent Visitor

Custom Column to count rows and divide

Situation: I have a list of phone numbers associated to multiple subaccounts (sub account 1 has 10 lines, sub  account 2 may have 27 lines, etc.). Each sub account has a flat fee associated (sub account 1 = $350, sub account 2 =$273, etc.) that needs to be divided equally across all lines within that account. I have merged the original tables into one that has a a column for phone number, sub account number, and account monthly charges. For what it's worth, I am appending the file each month with invoice info, so there will be duplicate phone numbers and sub-account rows but I don't think that would matter as the flat fee is static regardless of billing month.

 

How do I create a custom column that results in the math working out? 

dwalters_0-1671214257071.png   

dwalters_1-1671214287814.png

 

1 ACCEPTED SOLUTION
Barthel
Solution Sage
Solution Sage

Hey @dwalters,
You can perform the distribution based on the 'Group by' function. Go to your merged table and right click on the subsaccount column. Then select 'Group by'.

Barthel_0-1671283027219.png

Group the table by 'subaccount' and 'charge'. Add an extra column with 'All Rows' and a column with either 'Count Rows' or 'Count Distinct Rows'. If you want to take into account duplicate numbers in your distribution, choose 'Count Rows'. If not, choose 'Count Distinct Rows'.

Barthel_1-1671283454784.png

Expand the 'All Rows' column with the 'number' column. Now you have your original table again, with the number of wireless numbers per sub-account.  The last step is to add a custom column, where the charge is divided by the number of wireless numbers.

View solution in original post

3 REPLIES 3
Shaurya
Memorable Member
Memorable Member

Hi @dwalters,

 

Form what I understand, you want to assign monthly charge values in a new column based on the subaccount number. You can use this DAX formula to easily do that.

 

Monthly Charge = SWITCH(TRUE(),'Table'[Subaccount]=1,350,'Table'[Subaccount]=2,273,'Table'[Subaccount]=3,250,0)

 

Did I answer your question? Mark this post as a solution if I did!
Check out this blog of mine: How to Export Telemetry Data from Azure IoT Central into Power BI

Barthel
Solution Sage
Solution Sage

Hey @dwalters,
You can perform the distribution based on the 'Group by' function. Go to your merged table and right click on the subsaccount column. Then select 'Group by'.

Barthel_0-1671283027219.png

Group the table by 'subaccount' and 'charge'. Add an extra column with 'All Rows' and a column with either 'Count Rows' or 'Count Distinct Rows'. If you want to take into account duplicate numbers in your distribution, choose 'Count Rows'. If not, choose 'Count Distinct Rows'.

Barthel_1-1671283454784.png

Expand the 'All Rows' column with the 'number' column. Now you have your original table again, with the number of wireless numbers per sub-account.  The last step is to add a custom column, where the charge is divided by the number of wireless numbers.

Thanks, that is exactly what I needed. I've not had a lot of exposure nor success with grouping (particularly in the power query area of pbi). I really appreciate the help!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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