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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
batmanadk
Helper I
Helper I

First Value

I´ve edited the post to try to make it clearer. Thanks! 

So, This is a restaurant´s report and what we are trying to find out is what waiter sold the most of X product. So data is generated when a user enters it´s code and enters a product, that´s considered an order, that goes into a TICKET. 

What happens in the restaurant is that every user owns the table they first wait and one else but the cashier or supervisor can enter that table. The problem is that every order has a associated user but tickets only have last ticket user registered.

There are some products that can only be entered by the cashier or supervisor but not by the waiting staff. So when we make a visual with best selling users of one of those products, we want to see ticket users ranking, or ticket owner (meaning waiting staff or the person that first introduced an order into a ticket) but since every order registers a diferent users we always get that the best selling user is a supervisor or cashier.

So this is how the order table looks like.

TicketIdOrderIdUserProductRevenue
11ACoke10
12ABurger10
13ZSpecial10
24BBurger10
25ZSpecial10
36CBurger10
47DBurger10
48ZSpecial10
59EBurger10
510ESoda10
511ZSpecial10
612FBurger10
713GBurger10
714ZSpecial10

 

This is what we are trying to achieve something like the ¨TicketUserOwner¨ column

TicketIdOrderIdUserProductRevenueTicketUserOwner
11ACoke10A
12ABurger10A
13ZSpecial10A
24BBurger10B
25ZSpecial10B
36CBurger10C
47DBurger10D
48ZSpecial10D
59EBurger10E
510ESoda10E
511ZSpecial10E
612FBurger10F
713GBurger10G
714ZSpecial10G

 

So what is happening is what I´m getting in the upper right table, vs what we need in the lower right table.

Imagen Prueba Auto.jpg

 

I´ve tried some Dax using earlier and lookup 

 

TicketOwner =
VAR _PrevRow = LOOKUPVALUE(Orders[User],Orders[OrderId],Orders[OrderId]-1)
VAR _Idprevio = LOOKUPVALUE(Orders[TicketId] , Orders[OrderId], Orders[OrderId]-1)
RETURN
IF(
Orders[OrderId] = _Idprevio ,Orders[User],Orders[User])
 
The attached Pbi file is in the following link:
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @batmanadk 

According to your description and sample data, I think you want to get a column [Ticket User Owner] which is the first User group by Ticket Id, you can try this calculated column:

TicketUserOwner1 =

var _minorderid=

CALCULATE(MIN('Orders'[OrderId]),FILTER('Orders',[TicketId]=EARLIER(Orders[TicketId])))

return

CALCULATE(MIN('Orders'[User]),FILTER('Orders',[OrderId]=_minorderid))

Then place the column into the table chart to replace the original [TicketUserOwner], sort by [Revenue] desc, you can get what you want, like this:

v-robertq-msft_0-1607668864400.png

 

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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

View solution in original post

4 REPLIES 4
v-robertq-msft
Community Support
Community Support

Hi, @batmanadk 

According to your description and sample data, I think you want to get a column [Ticket User Owner] which is the first User group by Ticket Id, you can try this calculated column:

TicketUserOwner1 =

var _minorderid=

CALCULATE(MIN('Orders'[OrderId]),FILTER('Orders',[TicketId]=EARLIER(Orders[TicketId])))

return

CALCULATE(MIN('Orders'[User]),FILTER('Orders',[OrderId]=_minorderid))

Then place the column into the table chart to replace the original [TicketUserOwner], sort by [Revenue] desc, you can get what you want, like this:

v-robertq-msft_0-1607668864400.png

 

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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

Hey @v-robertq-msft ! Thanks a lot for the help! You really saved me! 

v-robertq-msft
Community Support
Community Support

Hi, @batmanadk 

According to your description, I can roughly understand your expression but I’m confused about what’s the “best selling staff (that is not the supervisor)”, I can not get clear information through the sample table you posted. I also can’t find your sample PBI desktop file. Would you like to take a look and post the sample file and explain your requirement in detail(using some pictures to show the expected output)?

Thanks very much!

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

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

I´m getting an error message when trying to reply with all details, I´ve edited the original post, hope it´s clearer. Thnaks a lot

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors