Forum Discussion

fadingvision's avatar
fadingvision
Frequent Visitor
7 years ago
Solved

Add a column based on multiple conditions

Hello Everybody,

I'm pretty new to Power BI, maybe some of you can help me.

On this table i need to add a column that would be filled by the requested quantity (SOLICITADO) and distributed by stock quantity (CANTIDAD DISPONIBLE). Since the stock is limited, it must consider client's priority (PRIORIDAD; 1=HIGHEST PRIORITY) and purchase order's date (FECHA O/C) in this particular order.

The tricky thing is that i need that the stock number somehow was decreasing o descounting as the products were asigned to the priority clients and keep asigning the remaining to the less priority ones (it can be done?).

*Requested products and stock are from different tables related by CAI (ID)

 

This is the table i'm filling

 

Here an example with values

CLIENTE GRUPO,CLIENTE CHILE,CAI,FECHA O/C,SOLICITADO,CANTIDAD DISPONIBLE,CDR,PRIORIDAD
KMTS,KMTS CHL S..,302244,2018-05-14 00:00:00,152,66,,2
BHP,MNR SCNDD LTD.,532463,2018-08-01 00:00:00,123,26,120,1
MS,MNR LS PLMBRS,302446,2018-05-16 00:00:00,120,184,207,2
NMX,MPRTDR Y DSTRBDR NMX S.,123425,2018-08-01 00:00:00,90,2,15,2
BHP,C.MNR CRR CLRD LTD,274589,2018-08-01 00:00:00,81,5,1,1
KLTR,KL TR S..,845075,2018-08-01 00:00:00,80,,78,1
KGHM,SRR GRD SCM,302446,2018-01-11 00:00:00,70,184,207,2
CV,NGNR CVL VCNT S..,349567,2017-12-29 00:00:00,64,13,29,2
GLNCR,C.MNR XSTRT LMS BYS.,289227,2017-11-01 00:00:00,61,2,13,1

Let me know if you need something else or if i wasn't clear about my issue.

 

Thanks in advance!

Regards