Forum Discussion
Show most recent version/status for an order
I have a data set of orders. An order can be one of a few status.
It starts out in Draft.
It moves to either InProgress or rejected.
It can then move to appealed.
I need to display one row for each order, along with the most recent status. I have the created date of each row.
The below screenshot shows the data, and ther is a link to a powerbi pbix with the data loaded.
Id appreciate some expertise in figuring this out as im unsure where to start.
Thank you for any expertise provided.
https://1drv.ms/u/s!AgldA0VQfPV9hNFJRlvQ2Y_4EXQggg
That looks like a form of Slowly Changing Dimension. Normally the current row would be marked with a column (and that usually comes from your source system)
If you don't have that mark from the source system, add a column like this
Column = VAR _maxDate = CALCULATE(MAX(FactTable[createdDate]), FILTER(FactTable, FactTable[orderid] = EARLIER(FactTable[OrderID]))) RETURN IF (FactTable[createdDate] = _maxDate, "Y")
Please test this, as I have just looked at it quickly.
Once you have this column, you can filter your table to return only rows where Column = "Y"
2 Replies
- HotChilli
Community Champion
That looks like a form of Slowly Changing Dimension. Normally the current row would be marked with a column (and that usually comes from your source system)
If you don't have that mark from the source system, add a column like this
Column = VAR _maxDate = CALCULATE(MAX(FactTable[createdDate]), FILTER(FactTable, FactTable[orderid] = EARLIER(FactTable[OrderID]))) RETURN IF (FactTable[createdDate] = _maxDate, "Y")
Please test this, as I have just looked at it quickly.
Once you have this column, you can filter your table to return only rows where Column = "Y"
- wilson_smyth
Post Patron
Thank you @HotChilli, this has worked. I never even considered looking at it like a slowly changing dimension.
Thank you for your expertise on this.