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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
POSPOS
Post Partisan
Post Partisan

Derive a new column based on other values

Hi All,

I have a requirement as below: 

Sample data:

User NameStatusNew Column
ANo FundWith Fund
AWith FundWith Fund
AExcludeWith Fund
BNo fundNo fund
BNo fundNo fund
CNo FundNo Fund
CExcludeNo Fund
CExcludeNo Fund
CNo FundNo Fund
DWith FundWith Fund
DWith FundWith Fund
DExcludeWith Fund
EExcludeExclude
EExcludeExclude

 

I have Username and Status column. Requirement is to create a new column using DAX  based on the below criteria:

If, user name has "With Fund" as one of the status, then the new column="With Fund"

If, user name does not have  "With Fund" and has "No Fund" as one of the status, then the new column="No Fund"

If, user name has only "Exclude" , then the new column="Exclude"

 

I would like to do this using DAX and not M query as there are other logics behind the data. The data provide above is a sample data only.

 

Thank you.

2 ACCEPTED SOLUTIONS
pankajnamekar25
Super User
Super User

Hello @POSPOS 

Try this DAX code to create column

New Column =

VAR CurrentUser = 'Table'[User Name]

VAR HasWithFund =

    CALCULATE(

        COUNTROWS('Table'),

        'Table'[User Name] = CurrentUser,

        'Table'[Status] = "With Fund"

    ) > 0

VAR HasNoFund =

    CALCULATE(

        COUNTROWS('Table'),

        'Table'[User Name] = CurrentUser,

        'Table'[Status] = "No Fund"

    ) > 0

RETURN

    IF(HasWithFund, "With Fund",

        IF(HasNoFund, "No Fund", "Exclude")

    )

 

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

View solution in original post

DataNinja777
Super User
Super User

Hi @POSPOS ,

 

You want to derive a new column using DAX based on the overall presence of statuses per user, not just per row. So even if one row for a user is "No Fund" or "Exclude", if any row for that user is "With Fund", then all rows for that user should get "With Fund".

This screams calculated column using a DAX logic like “look at all rows for the same user and check if any match ‘With Fund’, then fallback to ‘No Fund’, otherwise ‘Exclude’.”

Here’s the DAX magic that gets the job done:

New Column =
VAR HasWithFund =
    CALCULATE(
        COUNTROWS('YourTable'),
        ALLEXCEPT('YourTable', 'YourTable'[User Name]),
        'YourTable'[Status] = "With Fund"
    )
VAR HasNoFund =
    CALCULATE(
        COUNTROWS('YourTable'),
        ALLEXCEPT('YourTable', 'YourTable'[User Name]),
        'YourTable'[Status] = "No Fund"
    )
RETURN
    IF(
        HasWithFund > 0,
        "With Fund",
        IF(
            HasNoFund > 0,
            "No Fund",
            "Exclude"
        )
    )

This works because:

  • ALLEXCEPT keeps the filter context only for the 'User Name' so you're looking at the status across all rows for that user.
  • We check "With Fund" first because it's the top priority.
  • Then "No Fund" gets the second place trophy.
  • If none of the above, they’re stuck in "Exclude" land.

Let me know if your actual table has a different name or you want to make this dynamic for visuals — that’d be a measure instead of a column.

 

Best regards,

View solution in original post

2 REPLIES 2
DataNinja777
Super User
Super User

Hi @POSPOS ,

 

You want to derive a new column using DAX based on the overall presence of statuses per user, not just per row. So even if one row for a user is "No Fund" or "Exclude", if any row for that user is "With Fund", then all rows for that user should get "With Fund".

This screams calculated column using a DAX logic like “look at all rows for the same user and check if any match ‘With Fund’, then fallback to ‘No Fund’, otherwise ‘Exclude’.”

Here’s the DAX magic that gets the job done:

New Column =
VAR HasWithFund =
    CALCULATE(
        COUNTROWS('YourTable'),
        ALLEXCEPT('YourTable', 'YourTable'[User Name]),
        'YourTable'[Status] = "With Fund"
    )
VAR HasNoFund =
    CALCULATE(
        COUNTROWS('YourTable'),
        ALLEXCEPT('YourTable', 'YourTable'[User Name]),
        'YourTable'[Status] = "No Fund"
    )
RETURN
    IF(
        HasWithFund > 0,
        "With Fund",
        IF(
            HasNoFund > 0,
            "No Fund",
            "Exclude"
        )
    )

This works because:

  • ALLEXCEPT keeps the filter context only for the 'User Name' so you're looking at the status across all rows for that user.
  • We check "With Fund" first because it's the top priority.
  • Then "No Fund" gets the second place trophy.
  • If none of the above, they’re stuck in "Exclude" land.

Let me know if your actual table has a different name or you want to make this dynamic for visuals — that’d be a measure instead of a column.

 

Best regards,

pankajnamekar25
Super User
Super User

Hello @POSPOS 

Try this DAX code to create column

New Column =

VAR CurrentUser = 'Table'[User Name]

VAR HasWithFund =

    CALCULATE(

        COUNTROWS('Table'),

        'Table'[User Name] = CurrentUser,

        'Table'[Status] = "With Fund"

    ) > 0

VAR HasNoFund =

    CALCULATE(

        COUNTROWS('Table'),

        'Table'[User Name] = CurrentUser,

        'Table'[Status] = "No Fund"

    ) > 0

RETURN

    IF(HasWithFund, "With Fund",

        IF(HasNoFund, "No Fund", "Exclude")

    )

 

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors