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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DsIshukone
Regular Visitor

Select values and return corresponding values associated within group of selected values

Hi community,

 

I'm now facing a quite tricky situation that I will need help from you experts, so here's the situation:

 

I have a dataset, in this dataset there's ID, Long for longitude, Lat for Latitude, Pix (a coordinate in Lambert Conformal Conic format, it has 2 parts, one for x and one for y), and Score. Records with different Long and Lat will be grouped into the same Pix (e.g., Records 1 to 5 with same Pix x10000_y10000, even though their Long and Lat are totally different, Records 6 to 8 with same Pix x10800_y10000).

 

What I want to achieve, for examle if I select Pix equals x10800_y10000 (which is records 6 to 8), the results will return records 6 to 8, as well as records 1 to 5.

 

Let me explain, by selecting Pix x10800_y10000, I want to return all records based on 2 conditions:

1. whose Pix for x is within 1000 of 10800, meaning Pix for x is between 9800 and 11800; 

2. whose Pix for y is within 1000 of 10000, meaning Pix for y is between 9000 and 11000

 

So here, for records 1 to 5, their Pix is x10000_y10000, so the Pix for x is 10000, which is between 9800 and 11800; the Pix for y is 10000, also between 9000 and 11000, both conditions met, thus records 1 to 5 will be returned, along with records 6 to 8. Other records will not be returned, because at least 1 condition is not met.

 

Thank you in advance!

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

Hi @DsIshukone 

 

For your question, here is the method I provided:

 

Since, you need to transform the data. In order to present the data, I would suggest you to duplicate an identical table and create a relationship based on the ID column.

 

vnuocmsft_0-1714441088717.png

 

Enter the power query screen.

 

Select the Pix column and click Split Column by Delimiter in Transform.

 

vnuocmsft_1-1714441554966.png

 

vnuocmsft_2-1714441608094.png

 

vnuocmsft_3-1714441658693.png

 

Select the Pix.1 column and click Split Column by Positions in Transform.

 

vnuocmsft_5-1714441760174.png

 

vnuocmsft_6-1714441794240.png

 

Select the Pix.1.1 and Pix.1.2 columns and click Pivot Column in Transform.

 

vnuocmsft_7-1714441906320.png

 

vnuocmsft_8-1714441945715.png

 

vnuocmsft_9-1714441966535.png

 

Do the same for Pix.2. You will get data like this:

 

vnuocmsft_10-1714442094640.png

 

Close & Apply.

 

vnuocmsft_11-1714442146273.png

 

Create a measure.

 

_ID = 
IF(
    SELECTEDVALUE('Copy Table'[x]) <= 10800 
    && 
    SELECTEDVALUE('Copy Table'[y]) <= 10000, 
    CALCULATE(SELECTEDVALUE('Copy Table'[ID])), 
    BLANK()
)

 

Here is the result.

 

vnuocmsft_12-1714442263698.png

 

Regards,

Nono Chen

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

2 REPLIES 2
v-nuoc-msft
Community Support
Community Support

Hi @DsIshukone 

 

For your question, here is the method I provided:

 

Since, you need to transform the data. In order to present the data, I would suggest you to duplicate an identical table and create a relationship based on the ID column.

 

vnuocmsft_0-1714441088717.png

 

Enter the power query screen.

 

Select the Pix column and click Split Column by Delimiter in Transform.

 

vnuocmsft_1-1714441554966.png

 

vnuocmsft_2-1714441608094.png

 

vnuocmsft_3-1714441658693.png

 

Select the Pix.1 column and click Split Column by Positions in Transform.

 

vnuocmsft_5-1714441760174.png

 

vnuocmsft_6-1714441794240.png

 

Select the Pix.1.1 and Pix.1.2 columns and click Pivot Column in Transform.

 

vnuocmsft_7-1714441906320.png

 

vnuocmsft_8-1714441945715.png

 

vnuocmsft_9-1714441966535.png

 

Do the same for Pix.2. You will get data like this:

 

vnuocmsft_10-1714442094640.png

 

Close & Apply.

 

vnuocmsft_11-1714442146273.png

 

Create a measure.

 

_ID = 
IF(
    SELECTEDVALUE('Copy Table'[x]) <= 10800 
    && 
    SELECTEDVALUE('Copy Table'[y]) <= 10000, 
    CALCULATE(SELECTEDVALUE('Copy Table'[ID])), 
    BLANK()
)

 

Here is the result.

 

vnuocmsft_12-1714442263698.png

 

Regards,

Nono Chen

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

 

 

 

 

 

 

 

 

 

 

DsIshukone
Regular Visitor

Sample dataset looks like:

IDLongLatPixScore
11010x10000_y10000123
21011x10000_y10000456
31012x10000_y10000789
41111x10000_y10000321
51211x10000_y10000654
62020x10800_y100001121
72021x10800_y100001123
82121x10800_y100001125
93030x11900_y106004022
103031x11900_y106004025
113032x11900_y106004028
123130x11900_y106004029
134040x20000_y10000305
144041x20000_y10000306
154042x20000_y10000307
164142x20000_y10000308

 

What I want it returns upon selecting Pix equals x10800_y10000:

IDLongLatPixScore
11010x10000_y10000123
21011x10000_y10000456
31012x10000_y10000789
41111x10000_y10000321
51211x10000_y10000654
62020x10800_y100001121
72021x10800_y100001123
82121x10800_y100001125

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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