Forum Discussion
Rankx an Aggregated Fieldin a calculated column while ignoring others.
Hello all,
I'm trying to rank customers by the SUM (Total POS $) and am having difficulty getting Rankx to work as I would like it to. I have the following table: In this case, what I would like to do would be to aggregrate Total POS $ for each pos_end_customer_name for the month. I would like to ignore for the time being business_group and vp_area_description. Example on Feb 1st, I would like to aggregate $ for Zyteq (197 + 32) and rank this against all other unique customers throughout the rest of the month. I've tried the following:
But I am met with an error: "Column 'Sum Total $' cannot be found or may not be used in this expression."
Thanks!
Matthew
5 Replies
- AlB
Community Champion
Can you please share the table in the screen capture in text-tabular format so that it can be readily copied? Just use 'Copy table' in Power BI and paste it here. Or, ideally, share the pbix (beware of confidential data).
- Matthew_Theis
Advocate II
Here you are AlB Thanks in advance.
pos_date business_group vp_area_description pos_end_customer_name Total POS $ Total POS Q Rank C Rank Customers by Month Rank Customers by Month by BG Index Friday, February 1, 2019 CBG EUROPE ZYTEQ TECHNOLOGIES 70 632 #ERROR 26519 12694 1823291 Friday, February 1, 2019 CBG EUROPE ZYTEQ 197 2160 #ERROR 19180 9143 1823289 Friday, February 1, 2019 FEBG EUROPE ZYTEQ 32 210 #ERROR 32680 8170 1823290 Friday, March 1, 2019 CBG AMERICAS ZYNEX MEDICAL INC 17 400 #ERROR 23955 12577 1856519 Friday, February 1, 2019 CBG AMERICAS ZYNEX MEDICAL 563 20000 #ERROR 12414 5920 1823287 Friday, March 1, 2019 CBG AMERICAS ZYNEX MEDICAL 15 370 #ERROR 24527 12915 1856518
- v-cherch-msft
Microsoft Employee
You may try below calculated column:
Column = RANKX ( FILTER ( salesdashboard_pos, salesdashboard_pos[pos_date] = EARLIER ( salesdashboard_pos[pos_date] ) ), CALCULATE ( SUM ( salesdashboard_pos[Total POS $] ), ALLEXCEPT ( salesdashboard_pos, salesdashboard_pos[pos_end_customer_name], salesdashboard_pos[pos_date] ) ), , DESC )Regards,
- Matthew_Theis
Advocate II
Hello v-cherch-msft and thank you for the input. The calculation that you provided gets us very close to the desired solution. What's happening is that we are ranking with a Skip by sum(Total POS $). If we change to Dense, that will solve the problem towards the top end of the list, where sum(Total POS $) is unique for each customer. We run into a problem towards the bottom of the order where many distinct customers share the same value of sum(Total POS $). I would like to see a ranking for distinct customers...which is where a Skip would make sense, but that doesn't work at the top of the list (Ex. Zyteq Technologies should have a rank of 3).
I kept at it with this...Total Customer Sales per Month =VARCurrentDate =salesdashboard_pos[pos_date]VARCurrentCustomer =salesdashboard_pos[pos_end_customer_name]ReturnCALCULATE(SUMX(FILTER(ALL(salesdashboard_pos),salesdashboard_pos[pos_date]=CurrentDate &&salesdashboard_pos[pos_end_customer_name]=CurrentCustomer),salesdashboard_pos[Total POS $]))
and then I ranked that Dense...This looks alright at the top, but lower you begin to see the issue. 1. Kelei has a counterpart somewhere else with a Total POS $ of 1 and Rank per Month of 4786. It's at this point, where multiple distinct customers share the same Total Customer Sales per Month (also Rank) where we would want to skip the rank. Any ideas on how to solve this issue?Thanks!Matthew- v-cherch-msft
Microsoft Employee
Could you share some simplified sample data which could reproduce your scenario and your desired output?
Regards,