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 August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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