The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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!!!