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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
ppatel91
Helper I
Helper I

Get the unique customers with the highest Item value in Table Visualization

Hello there,

 

I am struglling to getting top 25 unique customers when filter the table using Alert_Id. Basically, I have these columns in table which you can find in csv file. The goal is to show top 25 unique customers based on highest value. The Item can be repeated but name has to be unique. I have tried so many different things but nothing seems to be working as expected because of Multiple customers have used multiple items and hence I am getting duplicate rows. The table has to be dymic because whenever user filters the table using Alert_id it should return those top unique customers that associated with Alert_id(Alert_id is a single selection). So whenever user select their Alert_id that table should display their data. I have tried below measure,
First I created calculated column to break the tie for price because many Item shares the same price:

max price = Table[PRICE] + RAND()

Then I created another column to get max price for the customer name:

MAX column for table = CALCULATE(MAX('Table'[max price]), ALLEXCEPT(Table, Table[CUSTOMER_NAME]))

Then I created calculated table using these columns:

distinct cont table for vw =
SELECTCOLUMNS(
    FILTER(Table, Table[max price]=Table[MAX column for table]), "Name" ,Table[CUSTOMER_NAME],"Item",Table[ITEM], "PRICE",Table[MAX column for table], "Alert_ID", Table[ID],  "DATE", Table[REQ_DATE], "ITEM_COUNT", Table[PK])

But, this is giving me all unique customers with the MAX value and I am getting blank table when I filter with Alert_ID even thought it has data but the customers are not with the MAX value. Basically, It's not dynamically capturing max values for each customer_name when filter is applied. And, I if there are multiple rows with same customer name which can have same exact value then I would choose any random row without considering which ITEM it is. I just want top 25 unique customers for one Alert_ID.

Here is the sample data,
ppatel91_0-1673046316121.png

 

Here is expected output if I select Alert_ID = 123 from filter and it can be different when I select different Alert_ID.

ppatel91_1-1673046463272.png


FYI: I have tried topn with max price and even with RANKX but no luck. I always endedup having multiple customers. 

Any help or lead will be highly appreciated!



1 ACCEPTED SOLUTION
ppatel91
Helper I
Helper I

I was able to figure out how to get unique values. Here is the solution that worked for me.
First, I created calculated column with my price column:

sum value = Table[PRICE] + RAND()

Then, I have created one measure that calculates the rank:

rank with table = 
RANKX(
    CALCULATETABLE(
        VALUES('Table'[ITEM]),
        ALLSELECTED('Table'[ITEM])
    ),
    CALCULATE(SUM(Table[sum value])),
    ,DESC,
    Dense
)

Then I applied the filter on NAME column to get top 25 based on sum value calculated column. Also, dragged my measure on filters pane and applied the filter where Rank with table = 1. 

That's how I got unique names with highest valued ITEM.

View solution in original post

6 REPLIES 6
ppatel91
Helper I
Helper I

I was able to figure out how to get unique values. Here is the solution that worked for me.
First, I created calculated column with my price column:

sum value = Table[PRICE] + RAND()

Then, I have created one measure that calculates the rank:

rank with table = 
RANKX(
    CALCULATETABLE(
        VALUES('Table'[ITEM]),
        ALLSELECTED('Table'[ITEM])
    ),
    CALCULATE(SUM(Table[sum value])),
    ,DESC,
    Dense
)

Then I applied the filter on NAME column to get top 25 based on sum value calculated column. Also, dragged my measure on filters pane and applied the filter where Rank with table = 1. 

That's how I got unique names with highest valued ITEM.

Ashish_Mathur
Super User
Super User

Hi,

I am not sure how much i can help but i would like to try.  Share data in a format the can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello Ashish, 

 

 

NAME	ITEM	DATE	ITEM_COUNT	PRICE
PMC	ITEM_1	2022-06-06	3	7636.5
A&A	ITEM_2	2022-05-02	3	6228
JKL	ITEM_2	2022-07-19	3	6228
JKL	ITEM_3	2022-07-19	3	5827.41
A&A	ITEM_3	2022-05-02	3	5827.41
JKL	ITEM_1	2022-07-19	3	4581
A&A	ITEM_1	2022-05-02	3	4581
PLUM	ITEM_1	2022-04-08	2	4072.5
A&A	ITEM_5	2022-05-02	3	3622.5
JKL	ITEM_5	2022-07-19	3	3622.5

 

 

NAMEITEMDATEITEM_COUNTPRICE
PMCITEM_12022-06-0637636.5
A&AITEM_22022-05-0236228
JKLITEM_22022-07-1936228
JKLITEM_32022-07-1935827.41
A&AITEM_32022-05-0235827.41
JKLITEM_12022-07-1934581
A&AITEM_12022-05-0234581
PLUMITEM_12022-04-0824072.5
A&AITEM_52022-05-0233622.5
JKLITEM_52022-07-1933622.5

Could you show the expected result please?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Yes, the second screenshot is expected result.

Hi,

Despite my best effort, i just cannot understand your question.  You mention about filtering by a certain Alert_ID when infact in the table that you have shared there is no Alert_ID at all.  May be someone else who understands your question can help. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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