Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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.
Help 🙂
Solved! Go to Solution.
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 )
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 )
Thanks!!!
User | Count |
---|---|
97 | |
76 | |
76 | |
48 | |
26 |