The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Ops, someone help me?
@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))
Hi Greg,
I tried your solution, and can find the column but the results are wrong.
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
User | Count |
---|---|
26 | |
12 | |
8 | |
8 | |
5 |
User | Count |
---|---|
30 | |
14 | |
12 | |
12 | |
7 |