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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PeterStuhr
Helper V
Helper V

Check if one of many rows contains value

Hi all,

 

We have a Sales Table containing

 

JobID, ServiceTypeID

 

An example could be:

 

JobIDServiceID
11
12
21
23

 

If I want to mark the JobIDs that includes ServiceID 3, how would I do that?

 

I do not just want to filter for ServiceID = 3, as I want to see all Services included for the JobID.

 

So in the above example, JobID 2 contains ServiceID 1 and 3. I would love to see both in a table.

 

So ideally, my output would be something like:

 

 

JobIDServiceIDMarked
11FALSE
12FALSE
21TRUE
23TRUE
1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @PeterStuhr 

Try this measure

Measure = 
VAR _JobIDs = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[ServiceID]=3),"Job_ID",[JobID]))
RETURN
IF(SELECTEDVALUE('Table'[JobID]) IN _JobIDs, "True", "False")

062103.jpg

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @PeterStuhr 

Try this measure

Measure = 
VAR _JobIDs = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[ServiceID]=3),"Job_ID",[JobID]))
RETURN
IF(SELECTEDVALUE('Table'[JobID]) IN _JobIDs, "True", "False")

062103.jpg

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Thanks for this answer, 

 

I was able to apply it for my problem.

I would like to compare if the one Service-ID is part of a list of Job IDs (around 700) but the performence of this measure is very slow. Do you have any idea how I can improve it because the data set I use is a bigger one. 

 

Best 

Felix 

CNENFRNL
Community Champion
Community Champion

Screenshot 2021-06-17 110153.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Fowmy
Super User
Super User

@PeterStuhr 

To achieve this, first, you need to create a disconnected table. Click on New Table under Modeling > New Table.

You can find PBIX file below my signature

 

Fowmy_0-1623919555759.png

Create the following measure which will get the selected service ID from the new table and identify each row that falls under the same job id. Then assign it to the visual filter and set it equal to 1.

Service Selected = 

var __serviceselected = SELECTEDVALUE('Service Slicer'[ServiceID]) return
var __commonjobid = CALCULATE(MAX(Table1[JobID]), Table1[ServiceID] = __serviceselected)
return

    INT(HASONEVALUE(Table1[JobID]) && MAX(Table1[JobID]) = __commonjobid)

Fowmy_1-1623919687945.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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