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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Matthew_Theis
Advocate II
Advocate II

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: Ranking Customers.PNG 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: 

Rank C =
RANKX(
      SUMMARIZE(
            salesdashboard_pos,
            salesdashboard_pos[pos_date],
            salesdashboard_pos[pos_end_customer_name],
            "Sum Total $",
            SUM(salesdashboard_pos[Total POS $])
      ),
      MIN([Sum Total $]),
      ,
      DESC
)
But I am met with an error: "Column 'Sum Total $' cannot be found or may not be used in this expression."  
I do need this to be a calculated column so that I can perform analysis on the ranking value...ie Avg Rev for median customer +/- 500.  Any help would be greatly appreciated.

 

Thanks!

Matthew

5 REPLIES 5
v-cherch-msft
Employee
Employee

Hi @Matthew_Theis 

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
)

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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 =
VAR
CurrentDate =
salesdashboard_pos[pos_date]
VAR
CurrentCustomer =
salesdashboard_pos[pos_end_customer_name]
Return
CALCULATE(
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...
Ranking Customers2.PNGThis 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.  Ranking Customers3.PNGAny ideas on how to solve this issue?
 
Thanks!
Matthew

Hi @Matthew_Theis 

Could you share some simplified sample data which could reproduce your scenario and your desired output?

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AlB
Super User
Super User

Hi @Matthew_Theis 

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).

Here you are @AlB   Thanks in advance.

pos_datebusiness_groupvp_area_descriptionpos_end_customer_nameTotal POS $Total POS QRank CRank Customers by MonthRank Customers by Month by BGIndex
Friday, February 1, 2019CBGEUROPEZYTEQ TECHNOLOGIES70632#ERROR26519126941823291
Friday, February 1, 2019CBGEUROPEZYTEQ1972160#ERROR1918091431823289
Friday, February 1, 2019FEBGEUROPEZYTEQ32210#ERROR3268081701823290
Friday, March 1, 2019CBGAMERICASZYNEX MEDICAL INC17400#ERROR23955125771856519
Friday, February 1, 2019CBGAMERICASZYNEX MEDICAL56320000#ERROR1241459201823287
Friday, March 1, 2019CBGAMERICASZYNEX MEDICAL15370#ERROR24527129151856518

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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