Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I’ve read through a bunch of the examples on the forum but I’m struggling to relate it to my data and get my head around the logic.
I have three types of invoice and need to apply a calculation based on the invoice number.
In my “v_rpt_Invoices” table I have an “Invoice No” that starts with either MS, CW or PR (e.g. MS12345, etc.) and an “Invoice_Amount”
In my “v_rpt_Product” table I have “Extended_Price_Amount” and “Extended_Cost”
This isn’t the actual calculation but what I am trying to do is apply the following logic (I think)…
IF (v_rpt_Invoices[Invoice No]) = CW* THEN (v_rpt_Invoices[MarginExGST]) = (v_rpt_Invoices[Invoice_Amount]) * (3/11)
IF (v_rpt_Invoices[Invoice No]) = MS* THEN (v_rpt_Invoices[MarginExGST]) = (v_rpt_Invoices[Invoice_Amount]) * (4/11)
IF (v_rpt_Invoices[Invoice No]) = PR* THEN (v_rpt_Invoices[MarginExGST]) = (v_rpt_Product[Extended_Price_Amount]) - (v_rpt_Product[Extended_Cost])
I’m hoping it should look something like the below (I just don’t know what to do about the IF, THEN and *Wildcard…
MarginExGST =
IF (v_rpt_Invoices[Invoice No]) = CW* THEN sum(v_rpt_Invoices[Invoice_Amount]) * (3/11)
IF (v_rpt_Invoices[Invoice No]) = MS* THEN sum(v_rpt_Invoices[Invoice_Amount]) * (4/11)
IF (v_rpt_Invoices[Invoice No]) = PR* THEN sum(v_rpt_Product[Extended_Price_Amount]) - sum(v_rpt_Product[Extended_Cost])
Any help would be greatly appreciated!
Cheers
Hardy
Solved! Go to Solution.
HI @Hardz
This might be close
MarginExGST = VAR InvoiceType = LEFT(MIN(v_rpt_Invoices[Invoice No]),2) RETURN SWITCH( TRUE() , InvoiceType = "CW" , sum(v_rpt_Invoices[Invoice_Amount]) * (3/11) , InvoiceType = "MS" , sum(v_rpt_Invoices[Invoice_Amount]) * (4/11) , InvoiceType = "PR" , sum(v_rpt_Product[Extended_Price_Amount]) - sum(v_rpt_Product[Extended_Cost]) )
HI @Hardz
This might be close
MarginExGST = VAR InvoiceType = LEFT(MIN(v_rpt_Invoices[Invoice No]),2) RETURN SWITCH( TRUE() , InvoiceType = "CW" , sum(v_rpt_Invoices[Invoice_Amount]) * (3/11) , InvoiceType = "MS" , sum(v_rpt_Invoices[Invoice_Amount]) * (4/11) , InvoiceType = "PR" , sum(v_rpt_Product[Extended_Price_Amount]) - sum(v_rpt_Product[Extended_Cost]) )
Brilliant, thanks Phil!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
84 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |