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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
arnabmit
Helper I
Helper I

Equally distribute expenses to agents

I have accounts in the attached files, as in the first table. I need to equally distribute the unallocated cost for the month to each agent as Addl. Expenses.

arnabmit_0-1652890287111.png

 

I am trying to create the second table using SUMMARIZECOLUMNS. I have the formula working in excel, but I am lost trying to replicate it in DAX.

 

=SUMIFS($D$2:$D$19,$B$2:$B$19,B25,$A$2:$A$19,"Unallocated")/COUNTA(UNIQUE(FILTER($A$2:$A$19,($B$2:$B$19=B25)*($A$2:$A$19<>"Unallocated"))))

 

Excel 

Thanks for any help in advance!

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@arnabmit 

 

New_Table = 
VAR _original_tbl = 
	FILTER(
		'Table',
		'Table'[Agent] <> "Unallocated"
	)
VAR _additional_expense = 
	CALCULATETABLE(
		ADDCOLUMNS(
			VALUES('Table'[Month]),
			"@Unallocated_Amount", CALCULATE(SUM('Table'[Amount]))
		),
		'Table'[Agent] = "Unallocated"
	)
VAR _new_tbl = 
	ADDCOLUMNS(
		SUMMARIZE(
			FILTER(
				'Table',
				'Table'[Agent] <> "Unallocated"
			),	
		'Table'[Agent],
		'Table'[Month]
		),
		"Type", "Addl. Expenses",
		"Amount", DIVIDE(
					SUMX(FILTER(_additional_expense, 'Table'[Month] = EARLIER('Table'[Month])), [@Unallocated_Amount]),
					CALCULATE(DISTINCTCOUNT('Table'[Agent]), REMOVEFILTERS('Table'[Agent]), 'Table'[Agent] <> "Unallocated")
				)
	)
RETURN

	UNION(
		_original_tbl,
		_new_tbl
	)

 




2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

3 REPLIES 3
SpartaBI
Community Champion
Community Champion

@arnabmit 

 

New_Table = 
VAR _original_tbl = 
	FILTER(
		'Table',
		'Table'[Agent] <> "Unallocated"
	)
VAR _additional_expense = 
	CALCULATETABLE(
		ADDCOLUMNS(
			VALUES('Table'[Month]),
			"@Unallocated_Amount", CALCULATE(SUM('Table'[Amount]))
		),
		'Table'[Agent] = "Unallocated"
	)
VAR _new_tbl = 
	ADDCOLUMNS(
		SUMMARIZE(
			FILTER(
				'Table',
				'Table'[Agent] <> "Unallocated"
			),	
		'Table'[Agent],
		'Table'[Month]
		),
		"Type", "Addl. Expenses",
		"Amount", DIVIDE(
					SUMX(FILTER(_additional_expense, 'Table'[Month] = EARLIER('Table'[Month])), [@Unallocated_Amount]),
					CALCULATE(DISTINCTCOUNT('Table'[Agent]), REMOVEFILTERS('Table'[Agent]), 'Table'[Agent] <> "Unallocated")
				)
	)
RETURN

	UNION(
		_original_tbl,
		_new_tbl
	)

 




2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Thank you so much! This worked perfectly! Now to try and learn more of DAX 😅

@arnabmit my pleasure 🙂

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.