Forum Discussion
Creating Margin for mulitple customers
Hi there,
I have created a logic for one of the customer “A” with the below formula and it is working fine.
PickUpCost-Cost =
Var Cost = IF(Shipments[BilledOn]< DATE(2019,04,01), (1-0.228),
IF(Shipments[BilledOn]> DATE(2019,04,01) ||Shipments[BilledOn]< DATE(2020,04,01), (1-0.221), (0.219)))
Return
IF(
LOOKUPVALUE('Financials'[Income],'Financials'[Invoice],Shipments[Invoice])-LOOKUPVALUE('Financials'[Cost],'Financials'[Invoice],Shipments[Invoice]) = LOOKUPVALUE('Financials'[Profit],'Financials'[Invoice],Shipments[Invoice]),
IF(OR(LOOKUPVALUE('Financials'[ss],'Financials'[Invoice],Shipments[Invoice])<=0.2,
LOOKUPVALUE('Financials'[ss],'Financials'[Invoice],Shipments[Invoice])>=0.3),
Cost*LOOKUPVALUE('Financials'[PC- Income],'Financials'[Invoice],Shipments[Invoice]),
LOOKUPVALUE('Financials'[PC- cost], 'Financials'[Invoice],Shipments[Invoice])),
Cost*LOOKUPVALUE('Financials'[PC- Income],'Financials'[Invoice],Shipments[Invoice]))
Now I am trying to create same formula for multiple customers with different Margins but it is not working
Index | Start Date | End Date | A | B | C | D |
1 | 1/1/2018 | 3/31/2019 | 0.228 | 0.209 | 0.228 | 0.228 |
2 | 4/1/2019 | 3/31/2020 | 0.221 | 0.209 | 0.221 | 0.221 |
3 | 4/1/2020 | 3/31/2021 | 0.219 | 0.209 | 0.219 | 0.219 |
Could anyone please help how to create formula for all customers, its very urgent and very important.
I have tried using
(CALCULATE (FIRSTNONBLANK('Financials'[Income],1),FILTER(ALL('Financials'), 'Scope'[Invoice] = 'Shipments'[Invoice]))
instead of LOOKUP Function but still it is not working
Please let me know if any other details are required
Thanks in advance.
10 Replies
- bheepatel
Resolver IV
Hi Anonymous
One possible solution is to pivot your table so that you have your table in the same format as Table B below. You can use the pivot options available to you in Power Query.
Once you have that, you can create the measure similar to the one below, where you can change the Customer and BilledOnDate variables to suit your needs. Below screenshots show you examples for two different customers and billing dates.
Hope this helps!
- AnonymousNot applicable
Thanks for the reply.
I have created “GetValue” measure and I got Values for A,B,C,D
Below is the formula for Customer ‘A’ and I got the result.
PC-Cost =
Var Cost = IF( Shipments[BilledOn]< DATE(2019,04,01), (1-0.228), IF(Shipments[BilledOn]> DATE(2019,04,01)||Shipments[BilledOn]< DATE(2020,04,01), (1-0.221), (0.219)) )
Return
IF
( LOOKUPVALUE('Financials'[Income],'Financials'[Invoice],Shipments[Invoice])-LOOKUPVALUE('Financials'[Cost],'Financials'[Invoice],Shipments[Invoice]) = LOOKUPVALUE('Financials'[Profit],'Financials'[Invoice],Shipments[Invoice]), IF(OR(LOOKUPVALUE('Financials'[ss],'Financials'[Invoice],Shipments[Invoice])<=0.2, LOOKUPVALUE('Financials'[ss],'Financials'[Invoice],Shipments[Invoice])>=0.3),
Cost*LOOKUPVALUE('Financials'[PC- Income],'Financials'[Invoice],Shipments[Invoice]),
LOOKUPVALUE('Financials'[PC- cost], 'Financials'[Invoice],Shipments[Invoice])),
Cost*LOOKUPVALUE('Financials'[PC- Income],'Financials'[Invoice],Shipments[Invoice]))Now I have to create for all customers (ABCD)
Could you please let me know how can I use ‘’GetValue” in the above formula
- V-lianl-msft
Community Support
Hi Anonymous ,
Could you please share sample data or sample .pbix?
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- AnonymousNot applicable
Thanks for the response.
Please let me know how to share data so that i can share sample data.
- V-lianl-msft
Community Support
Hi Anonymous ,
Screenshot,Copy and paste sample data in a table,Cloud service like OneDrive for business.
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.