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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Calculated Column

Hello,

I have Calculated column Condition which are having True and False. I need to create custom column/measure which is based on True value if first True value then 1, for next True value then 2, and so on....

 

How can I achieve this?

ConditionValue
FALSE 
FALSE 
FALSE 
FALSE 
TRUE1
TRUE2
TRUE3
TRUE4
TRUE5
TRUE6
TRUE7
1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Just as @amitchandak mentioned, it is needed to add an index column. And then, you can also try to create a column or measure like so:

Column = 
IF (
    'Table'[Condition],
    RANKX ( FILTER ( 'Table', 'Table'[Condition] = TRUE () ), [Index],, ASC, DENSE )
)

rank-c.JPG

 

Measure = 
IF (
    SELECTEDVALUE ( 'Table'[Condition] ),
    RANKX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Condition] = TRUE () ),
        CALCULATE ( MAX ( 'Table'[Index] ) ),
        ,
        ASC,
        DENSE
    )
)

rank-m.JPG 

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Just as @amitchandak mentioned, it is needed to add an index column. And then, you can also try to create a column or measure like so:

Column = 
IF (
    'Table'[Condition],
    RANKX ( FILTER ( 'Table', 'Table'[Condition] = TRUE () ), [Index],, ASC, DENSE )
)

rank-c.JPG

 

Measure = 
IF (
    SELECTEDVALUE ( 'Table'[Condition] ),
    RANKX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Condition] = TRUE () ),
        CALCULATE ( MAX ( 'Table'[Index] ) ),
        ,
        ASC,
        DENSE
    )
)

rank-m.JPG 

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , You need to add an index column in the power query and then add this formula in DAX

 

a new column

countx(filter(Table, [index] <=earlier([index]) && [Condition] = true()), [index])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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