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
Anonymous
Not applicable

Measure to check for existence of two values in a column

Hi Community,

Following is me sample data set:

ExcelPBI_0-1627637278728.png

I would like to create two measures M1 & M2.

M1 = distinctcount(client id) where status = 'Closed' & reason is both 1 and 3. So M1 resultset looks like:

ExcelPBI_1-1627637474874.png

M2= distinctcount(client id) where status = 'Closed' & reason is NOT both 1 and 3( that is either 1 or 3 but not both 1 & 3). So M2 resultset looks like:

ExcelPBI_2-1627637547204.png

Many Thanks in advance!

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

maybe you can create a new table

New table = 
VAR tbl=FILTER('Table (2)',('Table (2)'[Reason]=1 ||'Table (2)'[Reason]=3)&&'Table (2)'[status]="closed")
VAR tbl2=ADDCOLUMNS(ADDCOLUMNS(tbl,"count",countx(FILTER(tbl,'Table (2)'[ClientID]=EARLIER('Table (2)'[ClientID])),'Table (2)'[Reason])),"type",if([count]=1,"M2","M1"))
return SELECTCOLUMNS(tbl2,"category",'Table (2)'[Category],"clientID",'Table (2)'[ClientID],"apnt_id",'Table (2)'[apnt_id],"status",'Table (2)'[status],"reason",'Table (2)'[Reason],"type",[type])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
ryan_mayu
Super User
Super User

@Anonymous 

maybe you can create a new table

New table = 
VAR tbl=FILTER('Table (2)',('Table (2)'[Reason]=1 ||'Table (2)'[Reason]=3)&&'Table (2)'[status]="closed")
VAR tbl2=ADDCOLUMNS(ADDCOLUMNS(tbl,"count",countx(FILTER(tbl,'Table (2)'[ClientID]=EARLIER('Table (2)'[ClientID])),'Table (2)'[Reason])),"type",if([count]=1,"M2","M1"))
return SELECTCOLUMNS(tbl2,"category",'Table (2)'[Category],"clientID",'Table (2)'[ClientID],"apnt_id",'Table (2)'[apnt_id],"status",'Table (2)'[status],"reason",'Table (2)'[Reason],"type",[type])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

Top Solution Authors