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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
user01
Helper I
Helper I

Rank Based on Selected Data from Scatterplot

I have pulled some data via DirectQuery. The two tables are "asum" and "po". There is a one-to-many relationship from asum to po. I use asum to make a scatter plot. For example, if I query ID = 5, then I get the subsets of asum and po with ID = 5. Then I use X1 as the x values and Y as the y values for the scatter plot. I have a simple table for po. I want a measure that ranks the Option column based on selected values in the scatter plot. So when the scatter plot is unflitered (no selection) the rank on the Option is just the Option. Then for example if I select Options 2, 3, and 5 in the scatter plot, the ranks will be 1, 2, 3 respectively. I want this desired rank for both asum and po (po has duplicate Options). Seems simple but I cannot figure it out. How can I accomplish this?

 

Table asum

IDOptionX1X2YMean
4115155210053
42853198130
4319672197868
5110338143136
5217965205462
5315958160555
5416159146456
5523285192981

 

Table po

IDOptionValueLevel
41500
417001
4117502
4117502
4125003
42500
4249501
43500
437001
437001
4342502
511000
514001
515002
515002
5115003
521000
5224001
531000
534001
534001
535002
535002
535003
535003
5310004
541000
544001
544001
545002
545002
545003
545003
545004
545004
545005
551000
554001
554001
555002
555002
555003
555003
555004
555004
555005
555005

 

Desired result on asum when Options 2, 3, 5 are selected on scatter plot

user01_0-1710363746207.png

 

Desired result on po when Options 2, 3, 5 are selected on scatter plot

user01_0-1710361429644.png

 

1 ACCEPTED SOLUTION
v-xiandat-msft
Community Support
Community Support

Hi @user01 ,

@Ashish_Mathur mentioned the relationships , and I will continue to add to it later in this section:

Below is my table1:

vxiandatmsft_0-1711008011632.png

Below is my table2:

vxiandatmsft_1-1711008027234.png

The following DAX might work for you:

 

Rank asum = 
VAR SelectedOptions = SELECTEDVALUE('asum'[Option])
RETURN
    RANKX(
     ALLSELECTED('asum'),
        CALCULATE(MAX('asum'[Option])),
        ,
        ASC,
        DENSE
    )


Rank po = 
VAR SelectedOptions = SELECTEDVALUE('po'[Option])
RETURN
    RANKX(
        ALLSELECTED('po'),
       
       
        CALCULATE(MAX('po'[Option])),
        ,
        ASC,
        DENSE
    )

 

The final output is shown in the following figure:

vxiandatmsft_2-1711008102230.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-xiandat-msft
Community Support
Community Support

Hi @user01 ,

@Ashish_Mathur mentioned the relationships , and I will continue to add to it later in this section:

Below is my table1:

vxiandatmsft_0-1711008011632.png

Below is my table2:

vxiandatmsft_1-1711008027234.png

The following DAX might work for you:

 

Rank asum = 
VAR SelectedOptions = SELECTEDVALUE('asum'[Option])
RETURN
    RANKX(
     ALLSELECTED('asum'),
        CALCULATE(MAX('asum'[Option])),
        ,
        ASC,
        DENSE
    )


Rank po = 
VAR SelectedOptions = SELECTEDVALUE('po'[Option])
RETURN
    RANKX(
        ALLSELECTED('po'),
       
       
        CALCULATE(MAX('po'[Option])),
        ,
        ASC,
        DENSE
    )

 

The final output is shown in the following figure:

vxiandatmsft_2-1711008102230.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

Which columns have you used in both tables for the 1 to Many relationship?  I do not see a way to do that because ID and Options in both tables have duplicates.


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

Sorry for being unclear. It is asum Option (one) to po Option (many). The SQL Server has all the data, but I just query one ID (eg. ID = 5) into Power Bi via Direct Query. So asum[Option] looks like it has no duplicates.

Your reply does not answer my question.


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

Hi Ashish, Sorry for the confusion. I am using the Option column from both tables as 1:Many. I only have loaded the subsets where ID = 5. So there are no duplicates from in asum[Option]. Can we pretend ID = 4 does not exist?

I do not understand your question/data at all.  Someone who does will help you.


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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.