Forum Discussion
Latest Order ID
Hi,
I would like to get the latest order ID. As of now, I am taking the order ID and giving the last option in the dropdown.
The above approach is giving me the wrong result.
For example,
For a given date range, the visual shows the last order as follows.
But the actual last order ID is
It is not taking as per the latest date.
Hi sshiny ,
It seems to me that when you use lastesd, it will only filter based on a single column and not associate it with a time column.
You can use the following method, either measure or column, which you can create with the following dax.lastorder = CALCULATE(MAX('Table'[Order ID]),FILTER(ALL('Table'),'Table'[Order Date]=CALCULATE(MAX('Table'[Order Date]),ALL('Table')) ))Output result:
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Lucien
2 Replies
- Jihwan_KimSuper User
Hi,
In my opinion, if you want to find a latest order number that is defined by another column ( order date column ), the implicit measure is not the good choice. The selected option in the screenshot (Last) means, the last order number which is the last in the same column.
I suggest writing a measure something like below and then put it into the visualization.
Without knowing more detail of the requirement, I assume that the latest order number means that happened on the latest order date and not within the certain category.
New measure: =
VAR _latestorderdate =
MAXX ( ALL ( 'TableName' ), 'TableName'[OrderDate] )
RETURN
CALCULATE (
MAX ( 'TableName'[OrderNumber] ),
FILTER ( ALL ( 'TableName' ), 'TableName'[OrderDate] = _latestorderdate )
) - v-luwang-msftCommunity Support
Hi sshiny ,
It seems to me that when you use lastesd, it will only filter based on a single column and not associate it with a time column.
You can use the following method, either measure or column, which you can create with the following dax.lastorder = CALCULATE(MAX('Table'[Order ID]),FILTER(ALL('Table'),'Table'[Order Date]=CALCULATE(MAX('Table'[Order Date]),ALL('Table')) ))Output result:
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Lucien