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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Chandrashekar
Resolver III
Resolver III

Column Formula : Based on condition

Hello,

Need help in column formula for below table. I am looking for formula based on column2.

If Number continuous and if it contains De then only formula should get 1 else 0.

For Ex: S1 - We have two occurrence and also we have De in it. So formula should get 1.
S2 - We have two occurrence but we do not have De in it so formula should get 0

Column2Column2Column3Expected Output
S1S1-Adad1
S1S1-Dede1
S2S2-Adad0
S2S2-SeSe0
S4S4-adad1
S4S4-SeSe1
S4S4-dede1


Regards,
Chandrashekar B

1 ACCEPTED SOLUTION

You are right, its becasue of SELECTEDVALUE(). could you try below, I just tested it, it works fine.

Flag = 
VAR _CurrentKey = 'Table'[Column1]
VAR _RowCount =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( ALL ( 'Table' ), 'Table'[Column1] = _CurrentKey )
    )
VAR _HasDe =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Column1] = _CurrentKey
                && CONTAINSSTRING ( LOWER ( 'Table'[Column2] ), "de" )
        )
    )
RETURN 
IF ( NOT ISBLANK ( _CurrentKey ) && _RowCount > 1 && _HasDe > 0, 1, 0 )

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

View solution in original post

4 REPLIES 4
cengizhanarslan
Super User
Super User

I believe you are looking a DAX to create a calculated column, not nmeasure. If so, please try the formula below:

Flag =
VAR _CurrentKey = Table[Column1]

VAR _RowCount =
    CALCULATE (
        COUNTROWS ( Table ),
        Table[Column1] = _CurrentKey
    )

VAR _HasDe =
    CALCULATE (
        COUNTROWS ( Table ),
        Table[Column1] = _CurrentKey,
        CONTAINSSTRING ( LOWER ( Table[Column2] ), "de" )
    )

RETURN
IF ( _RowCount > 1 && _HasDe > 0, 1, 0 )

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

Hello,

 

I tried but am getting 0.

Chandrashekar_0-1769065151154.png

 

Regards,

Chandrashekar B

You are right, its becasue of SELECTEDVALUE(). could you try below, I just tested it, it works fine.

Flag = 
VAR _CurrentKey = 'Table'[Column1]
VAR _RowCount =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( ALL ( 'Table' ), 'Table'[Column1] = _CurrentKey )
    )
VAR _HasDe =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Column1] = _CurrentKey
                && CONTAINSSTRING ( LOWER ( 'Table'[Column2] ), "de" )
        )
    )
RETURN 
IF ( NOT ISBLANK ( _CurrentKey ) && _RowCount > 1 && _HasDe > 0, 1, 0 )

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

Hello, Thank you it is working fine.

 

Regards,

Chandrashekar B

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.