Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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 |
Solved! Go to Solution.
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.
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.
@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])
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 44 | |
| 43 | |
| 38 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 64 | |
| 31 | |
| 29 | |
| 24 |