Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello!
I would like to create calculated column (to use as a slicer) when status change by using dax. Here is the example of data.
Solved! Go to Solution.
Hi @Anna_maija ,
Based on your requirement, here is my answer.
I create a table as you mentioned.
Then I go to the Power Query to insert an Index column.
Then I create an calculated column, here is the DAX code.
StatusChangeFlag =
VAR _PreviousIndex =
CALCULATE (
MAX ( 'Table'[Index] ),
FILTER ( ALL ( 'Table' ), 'Table'[Index] < EARLIER ( 'Table'[Index] ) )
)
VAR _PreviousStatus =
CALCULATE (
SELECTEDVALUE ( 'Table'[Status] ),
FILTER ( ALL ( 'Table' ), 'Table'[Index] = _PreviousIndex )
)
RETURN
IF ( _PreviousStatus <> BLANK () && 'Table'[Status] <> _PreviousStatus, 1 )
Finally, when we change the letter, it will give us a "1".
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anna_maija ,
Based on your requirement, here is my answer.
I create a table as you mentioned.
Then I go to the Power Query to insert an Index column.
Then I create an calculated column, here is the DAX code.
StatusChangeFlag =
VAR _PreviousIndex =
CALCULATE (
MAX ( 'Table'[Index] ),
FILTER ( ALL ( 'Table' ), 'Table'[Index] < EARLIER ( 'Table'[Index] ) )
)
VAR _PreviousStatus =
CALCULATE (
SELECTEDVALUE ( 'Table'[Status] ),
FILTER ( ALL ( 'Table' ), 'Table'[Index] = _PreviousIndex )
)
RETURN
IF ( _PreviousStatus <> BLANK () && 'Table'[Status] <> _PreviousStatus, 1 )
Finally, when we change the letter, it will give us a "1".
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
147 | |
85 | |
66 | |
52 | |
46 |
User | Count |
---|---|
215 | |
90 | |
83 | |
66 | |
58 |