Forum Discussion
New column based on a condition
Hi all,
I´m quite new into Power BI and I would like to create a column based on the following condition:
If a user has more than one market assigned (each row repeats the username and the unique market) I would like to call it as "EMEA", if the user has just a market, I would like the name of the market.
Any help is welcome 🙂
Hi @JorgeRG ,
Try the following calculated column:
column = IF ( COUNTROWS ( FILTER ( GROUPBY ( 'Table', 'Table'[User_Principal_Name], 'Table'[Market_Name] ), 'Table'[User_Principal_Name] = EARLIER ( 'Table'[User_Principal_Name] ) ) ) = 1, 'Table'[Market_Name], "EMEA" )If this works let me know so I can place it on the post:
3 Replies
- amitchandak
Super User
Anonymous , a new column
column =
var _1 = countx(filter(Table, [username] =earlier([user name]) , [Market Name]) +0
return
if(_1 >=1 , [User Name] & [Market Name] , [Market Name] )
- AnonymousNot applicable
Thanks amitchandak for your reply!
I forgot to add the structure of the table. Maybe this helps to see the column that I would like to get:
- MFelix
Super User
Hi @JorgeRG ,
Try the following calculated column:
column = IF ( COUNTROWS ( FILTER ( GROUPBY ( 'Table', 'Table'[User_Principal_Name], 'Table'[Market_Name] ), 'Table'[User_Principal_Name] = EARLIER ( 'Table'[User_Principal_Name] ) ) ) = 1, 'Table'[Market_Name], "EMEA" )If this works let me know so I can place it on the post: