cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Assigning Salesperson to Client based on number of orders

 

I'm trying to create a table showing who is the salesperson with more affinity with the client.

For that:

- Whoever had more orders from the client is "assigned" to the client.

- In case of a tie, the salesperson who did the last order is.  

 

Screen Shot 2018-01-27 at 21.20.46.png

Help 🙂 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User I
Super User I

@fva6937

 

Please try this MEASURE

 

Desired SalesPerson =
VAR myTable1 =
    TOPN (
        1,
        SUMMARIZE (
            SalesTable,
            SalesTable[Salesperson_ID],
            "Count", COUNT ( SalesTable[Salesperson_ID] )
        ),
        [Count], DESC
    )
VAR myTable2 =
    TOPN (
        1,
        SUMMARIZE ( SalesTable, SalesTable[Salesperson_ID], SalesTable[Date] ),
        SalesTable[Date], DESC
    )
VAR MostOrders =
    CALCULATE ( LASTNONBLANK ( SalesTable[Salesperson_ID], 1 ), mytable1 )
VAR LastOrder =
    CALCULATE ( LASTNONBLANK ( SalesTable[Salesperson_ID], 1 ), mytable2 )
RETURN
    IF ( COUNTROWS ( mytable1 ) = 1, MostOrders, LastOrder )
Regards,
Zubair


View solution in original post

2 REPLIES 2
Highlighted
Super User I
Super User I

@fva6937

 

Please try this MEASURE

 

Desired SalesPerson =
VAR myTable1 =
    TOPN (
        1,
        SUMMARIZE (
            SalesTable,
            SalesTable[Salesperson_ID],
            "Count", COUNT ( SalesTable[Salesperson_ID] )
        ),
        [Count], DESC
    )
VAR myTable2 =
    TOPN (
        1,
        SUMMARIZE ( SalesTable, SalesTable[Salesperson_ID], SalesTable[Date] ),
        SalesTable[Date], DESC
    )
VAR MostOrders =
    CALCULATE ( LASTNONBLANK ( SalesTable[Salesperson_ID], 1 ), mytable1 )
VAR LastOrder =
    CALCULATE ( LASTNONBLANK ( SalesTable[Salesperson_ID], 1 ), mytable2 )
RETURN
    IF ( COUNTROWS ( mytable1 ) = 1, MostOrders, LastOrder )
Regards,
Zubair


View solution in original post

Highlighted

Thanks!!!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors