Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sshiny
Helper II
Helper II

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.

sshiny_0-1661835616192.png

The above approach is giving me the wrong result.

 

For example,

For a given date range, the visual shows the last order as follows.

sshiny_1-1661835758880.png

 

But the actual last order ID is

sshiny_2-1661835919759.png

It is not taking as per the latest date.

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community 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:

vluwangmsft_0-1662453146343.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,
Lucien

View solution in original post

2 REPLIES 2
v-luwang-msft
Community Support
Community 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:

vluwangmsft_0-1662453146343.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,
Lucien

Jihwan_Kim
Super User
Super 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 )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.