Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi Im currently doing an excel to power bi conversion and i need help with working out dax for the followng excel formula which basically marks the first occurence of the 'course reference to' 1 and then any subsequent occurence of the same reference as 0 in a table. This marker is then used later for filtering data.
The current excel formula is
=IF(countif($b$2:b4)>1,0,1) - The B column being the course reference column. Just for reference the current cell formula looks at the previous columns to do its comparrision . so the first row formula is
=IF(countif($b$2:b2)>1,0,1) and then b3's formula is =IF(countif($b$2:b3)>1,0,1) and so fourth..
Solved! Go to Solution.
Alright, usually it helps if you give some example data, that would save us time in creating our own dataset to help you out 🙂
Either way, I've created a sample table, in which your question is: how can I mark row 7 and row 9 as second dublicate.
The first thing we are going to do in the Query Editor is to add an Index Column. This will help us in determining whether a value has already occurered or if it is the first occurence. Go to Add Column tab, en chose Add Index Column. The table now looks like this:
Now close and apply the query editor en go to the report page. We are going to add a custom column. This column will count the rows when we filter the table on the value column (Column1 in my case) and on the Index column where we want to see only rows where the index is lower or equal as the current row. The formula for the column is this:
Duplicate = IF(CALCULATE(COUNTROWS('Table'), FILTER('Table', 'Table'[Column1] = EARLIER('Table'[Column1]) && 'Table'[Index] <= EARLIER('Table'[Index]))) = 1, 1, 0)
The table now looks like this (from Data view):
Note that row 7 and 9 are marked 0 as the values A en E already occured.
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Kudo's are welcome 🙂
Proud to be a Super User!
Alright, usually it helps if you give some example data, that would save us time in creating our own dataset to help you out 🙂
Either way, I've created a sample table, in which your question is: how can I mark row 7 and row 9 as second dublicate.
The first thing we are going to do in the Query Editor is to add an Index Column. This will help us in determining whether a value has already occurered or if it is the first occurence. Go to Add Column tab, en chose Add Index Column. The table now looks like this:
Now close and apply the query editor en go to the report page. We are going to add a custom column. This column will count the rows when we filter the table on the value column (Column1 in my case) and on the Index column where we want to see only rows where the index is lower or equal as the current row. The formula for the column is this:
Duplicate = IF(CALCULATE(COUNTROWS('Table'), FILTER('Table', 'Table'[Column1] = EARLIER('Table'[Column1]) && 'Table'[Index] <= EARLIER('Table'[Index]))) = 1, 1, 0)
The table now looks like this (from Data view):
Note that row 7 and 9 are marked 0 as the values A en E already occured.
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Kudo's are welcome 🙂
Proud to be a Super User!
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
84 | |
84 | |
72 | |
49 |
User | Count |
---|---|
143 | |
130 | |
108 | |
64 | |
55 |