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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
neonguyen1803
Frequent Visitor

Return a column summarize in var keyword

Dear community, 

 

I have a table to record dept of customers. Then I wrote a dax to calculate Topn dept such as below:

 

Dept TOPN = 
var top_n = SELECTEDVALUE('TOPCUSTOMER'[TOP], 3)

var table_1 = SUMMARIZECOLUMNS(Customer[Customer ID], "Total Dept", SUM(Customer[Dept]))

return Calculate(SUM(table_1[Total Dept]), TOPN(top_n, table_1, [Total Dept], DESC))

 

But at the return step, I can't find column [Total Dept] (red tex) of table_1 (created with var keyword). Please explain for me this case

 

Thank you

3 REPLIES 3
neonguyen1803
Frequent Visitor

Ops, someone help me? 

Greg_Deckler
Community Champion
Community Champion

@neonguyen1803 Maybe:

Dept TOPN = 
var top_n = SELECTEDVALUE('TOPCUSTOMER'[TOP], 3)

var table_1 = SUMMARIZECOLUMNS(Customer[Customer ID], "Total Dept", SUM(Customer[Dept]))

return Calculate(SUMX(table_1,[Total Dept]), TOPN(top_n, table_1, [Total Dept], DESC))



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

I tried your solution, and can find the column but the results are wrong.

neonguyen1803_0-1683781211670.png

This is the total debt of all customers. The result does no change when I change Topn rank, eg. change to top3 or top 5 still get the result is 14.18bn

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.