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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

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 🙂

1 ACCEPTED SOLUTION

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:

 

MFelix_0-1635866705841.png

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
amitchandak
Super User
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] )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not 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:

 

JorgeRG_0-1635857380038.png

 

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:

 

MFelix_0-1635866705841.png

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.