Forum Discussion
chinma
2 years agoFrequent Visitor
Create Conditional Column from another RankBased Conditional Column
Hi Team,
I have a table (UniqueVendors) with columns (VendorName,VendorRank). Query for this table: "
UniqueVendors = UNION(DISTINCT('Vendor Vs Inventory'[VMNAME]),DATATABLE("VendorName",STRING,{{"Others"}}))".
I am trying to create a conditonal column (TargetVendorName) from another RankBased Column (VendorRank). My condition is :
TargetVendorName = IF(UniqueVendors[VendorRank]<=3, UniqueVendors[VendorName],"Others"). If I press "Enter" button after entering this condition, nothing gets created neither no error displayed.
Expected result is :
| VendorName | VendorRank | TargetVendorName |
| VEND_A | 1 | VEND_A |
| VEND_B | 2 | VEND_B |
| VEND_C | 3 | VEND_C |
| VEND_N | 4 | Others |
| VEND_F | 4 | Others |
| VEND_E | 4 | Others |
| VEND_D | 4 | Others |
| Others | 4 | Others |
| VEND_M | 4 | Others |
| VEND_J | 4 | Others |
| VEND_P | 4 | Others |
Please guide me on this.
Thank you
chinma you can use new RANK function to add the column:
Target Vendor Name = VAR __Rank = RANK ( DENSE, ALLSELECTED ( VendorTable ), ORDERBY ( [TotalSales], DESC ), MATCHBY ( VendorTable[VendorName] ) ) RETURN IF ( __Rank <= 3, VendorTable[VendorName], "Others" )