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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

calculate category column using nested IF

I want to calculate following column.

 

Sales Parent type

Franchise

Retail

Corporate

 This are the other column I should filter to evaluate the sales parent type as franchise or retail or corporate

IF(

('Query1'[WarehouseID]= "1"&& 'Query1'[ParentAccountID]  =  2151 && 'Query1'[InvoiceStatusID]= "IN" && 'Query1'[AccountLevel]= "3") ||

('Query1'[WarehouseID]= "2"&& 'Query1'[ParentAccountID]  =  8351 && 'Query1'[InvoiceStatusID]= "IN" && 'Query1'[AccountLevel]= "3") ||

('Query1'[WarehouseID]= "3"&& 'Query1'[ParentAccountID]  =  1251 && 'Query1'[InvoiceStatusID]= "IN" && 'Query1'[AccountLevel]= "3") ||)  then Retail

 

other wise

 

('Query1'[WarehouseID]= "1"&& 'Query1'[ParentAccountID]  =  1212 && 'Query1'[InvoiceStatusID]= "IN" && 'Query1'[AccountLevel]= "3") ||

('Query1'[WarehouseID]= "2"&& 'Query1'[ParentAccountID]  =  2211 && 'Query1'[InvoiceStatusID]= "IN" && 'Query1'[AccountLevel]= "3") ||

('Query1'[WarehouseID]= "3"&& 'Query1'[ParentAccountID]  =  1211 && 'Query1'[InvoiceStatusID]= "IN" && 'Query1'[AccountLevel]= "3") ||) then corporate

 

otherwise

 

('Query1'[WarehouseID]= "1"&& 'Query1'[ParentAccountID]  =  8212 && 'Query1'[InvoiceStatusID]= "IN" && 'Query1'[AccountLevel]= "3") ||

('Query1'[WarehouseID]= "2"&& 'Query1'[ParentAccountID]  =  2323 && 'Query1'[InvoiceStatusID]= "IN" && 'Query1'[AccountLevel]= "3") ||

('Query1'[WarehouseID]= "3"&& 'Query1'[ParentAccountID]  =  1219 && 'Query1'[InvoiceStatusID]= "IN" && 'Query1'[AccountLevel]= "3") ||) then franchise

 

 

2 REPLIES 2
GilbertQ
Super User
Super User

Hi @Anonymous

 

I would complete this in the Query Editor using the Custom Column. 

 

In doing it in this way it would come into your Power BI model with your definitions already defined.

 

A rough sample would be the following:

IF(
('Query1'[WarehouseID]= '1' and 'Query1'[ParentAccountID]  =  2151 and 'Query1'[InvoiceStatusID]= 'IN' and 'Query1'[AccountLevel]= 3') or
('Query1'[WarehouseID]= '2' and 'Query1'[ParentAccountID]  =  8351 and 'Query1'[InvoiceStatusID]= 'IN' and 'Query1'[AccountLevel]= '3') or
('Query1'[WarehouseID]= '3' and 'Query1'[ParentAccountID]  =  1251 and 'Query1'[InvoiceStatusID]= 'IN' and 'Query1'[AccountLevel]= '3'))  then Retail




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Anonymous
Not applicable

What result would you like should none of those conditions be met?  Franchise or blank?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.