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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
hlynurgudna
Frequent Visitor

Group each person only to one group

Hi all

 

I have this problem where I am trying to group together all the names which have the "I" marker and put them only in group X, and the other names that dont have the market "I" go in group Y.

 

I have been trying out different version of IF statements, Textcontains etc. but what happens then is that I always group for example name A in both group X and Y, when I only want to have it in group X

 

This is an example of my data, each person always has more than one marker per day so if I try something like if(name="I";"X";"Y")

Person A goes into both group X and Y

 

NameMarkerDate
AI8.3.2022
AIN8.3.2022
A88.3.2022
BIN8.3.2022
B88.3.2022
CI9.3.2022
C99.3.2022
CF9.3.2022
DI9.3.2022
D99.3.2022
DF9.3.2022

 

Here is an example of my desired output

NameDateGroup
A8.3.2022X
B8.3.2022X
C9.3.2022Y
D9.3.2022Y

 

Best regards

2 ACCEPTED SOLUTIONS
johnt75
Super User
Super User

OK, I think a summary table is probably still the way to go, it just needs a few tweaks.

Summary Table = SUMMARIZE( 'Table', 'Table'[Name], 'Table'[Date])

You won't need to create a relationship from the summary table to the base table, you should be able to add the Group column as something like

Group = 
var currentName = 'Table'[Name]
var currentDate = 'Table'[Date]
var filterTable = TREATAS( { ( currentName, currentDate) }, 'Table'[Name], 'Table'[Date])
var valuesTable = CALCULATETABLE( SELECTCOLUMNS( 'Table', "@marker", 'Table'[Marker]), filterTable )
var result = IF ( "I" IN valuesTable, "X", "Y" )
return result

View solution in original post

tamerj1
Community Champion
Community Champion

Hi @hlynurgudna 
One way to that 

Group = 
IF (
    { "I" } IN SELECTCOLUMNS ( 'Table', "Marker", 'Table'[Marker] ),
    "X",
    "Y"
)

Untitled.png

View solution in original post

5 REPLIES 5
tamerj1
Community Champion
Community Champion

Hi @hlynurgudna 
One way to that 

Group = 
IF (
    { "I" } IN SELECTCOLUMNS ( 'Table', "Marker", 'Table'[Marker] ),
    "X",
    "Y"
)

Untitled.png

Great, this works! Many thanks for the help

johnt75
Super User
Super User

OK, I think a summary table is probably still the way to go, it just needs a few tweaks.

Summary Table = SUMMARIZE( 'Table', 'Table'[Name], 'Table'[Date])

You won't need to create a relationship from the summary table to the base table, you should be able to add the Group column as something like

Group = 
var currentName = 'Table'[Name]
var currentDate = 'Table'[Date]
var filterTable = TREATAS( { ( currentName, currentDate) }, 'Table'[Name], 'Table'[Date])
var valuesTable = CALCULATETABLE( SELECTCOLUMNS( 'Table', "@marker", 'Table'[Marker]), filterTable )
var result = IF ( "I" IN valuesTable, "X", "Y" )
return result
johnt75
Super User
Super User

If the summary table you want to create does not need to be affected by any filters or slicers then I would create a calculated table as

Summary Table = DISTINCT( 'Table'[Name] )

and then create a 1-to-many relationship from that to your data table.

You could then add a calculated column as

Group = IF ( "I" IN SELECTCOLUMNS( RELATEDTABLE( 'Table' ), "@marker", 'Table'[Marker]), "X", "Y" )

Its not clear which date field is required. If its the minimum date then you could add that as MINX( RELATEDTABLE( 'Table'), 'Table'[Date]).

Hi John

 

Thanks for the answer. I forgot to mention that person A could be in group X on 8.3.2022 but be in group Y the day after, I´m sorry that I didnt include it in my data

 

So we could se example where this could happen

NameMarkerDate
AI8.3.2022
AIN8.3.2022
A88.3.2022
AIN9.3.2022
A89.3.2022

 

In this case person A should be in group X 8.3.2022 but in group Y 9.3.2022

Best regards

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.