cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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?

 Condition Value FALSE FALSE FALSE FALSE TRUE 1 TRUE 2 TRUE 3 TRUE 4 TRUE 5 TRUE 6 TRUE 7
1 ACCEPTED SOLUTION
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 )
)
``````

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

Best Regards,

Icey

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

2 REPLIES 2
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 )
)
``````

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

Best Regards,

Icey

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

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])

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors