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'm new with DAXand my logic is still with Excel.
Using Calculated Column with DAX (not in Power Query), how do I check my current record against previous record?
| Data | Desired Result |
A | 1 |
| A | 1 |
| B | 2 |
| B | 2 |
| B | 2 |
| C | 3 |
| C | 3 |
| D | 4 |
| E | 5 |
| F | 6 |
| F | 6 |
The logic that I want here is that if I'm the 1st record, then assign value 1 otherwise check against previous record, and if previous record is the same as current record, take the above assign value otherwise add 1
Thanks for the reply @Greg_Deckler .
I have questions regarding your DAX formula.
Using my table above as example,
@JustDavid You are going to need to add an Index to your table to be able to let DAX know what "before" is.
Sorry...I don't quite understand.
Even if I were to add an index column (I'd assume starting from 0), in which formula do I use it in?
Is it in VAR __PreviousData = MAXX(FILTER('Table','Table'[DATA] < EARLIER('Table'[DATA])),[INDEX])?
Again. How do I assign value 1 to the 1st record of the column 'Desired Result'?
Just to be clear, This is the logic that I had with Excel.
@JustDavid See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous
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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 68 | |
| 63 | |
| 31 | |
| 30 | |
| 23 |