This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi Everyone!
Need help with tweaking the performance of DAX formula.
I had to recreate the way Sage200c generates sales report. The code I ended up with looks like this:
Sales Value =
var Invoices = calculate(
sum('SOPInvoiceCreditLine'[LineTotalValueGBP]),
'SOPInvoiceCreditType'[Name]="Invoice",
'SOPOrderReturnType'[SOPOrderReturnTypeName]<>"Quotation")
var CreditNote = calculate(
sum('SOPInvoiceCreditLine'[LineTotalValueGBP]),
'SOPInvoiceCreditType'[Name]="Credit Note",
'SOPOrderReturnType'[SOPOrderReturnTypeName]<>"Quotation")*-1
Var SalesValue = calculate(
invoices+CreditNote,
filter(
SOPOrderReturnType,
SOPOrderReturnType[SOPOrderReturnTypeName]<>"Quotation"))
Return
IF(SELECTEDVALUE('DIM: Currency Exchange'[Currency])="GBP",SalesValue,SalesValue*SELECTEDVALUE('DIM: Live Currency Exchange'[USD per unit]))
When I run a performance analyzer, this formula and a corresponding one with the volumes (same code, different column in sum) takes the longest time to calculate. Is there any way to simplify them?
Thanks in advance!
Solved! Go to Solution.
Hi Daniel,
First you need to create a New Column with the below formula:
Total Value GBP =
Var CreditType = RELATED('SOPInvoiceCreditType'[Name])
Var ReturnTypeName = RELATED('SOPOrderReturnType'[SOPOrderReturnTypeName])
RETURN
SWITCH(TRUE()
, CreditType = "Credit Note" && ReturnTypeName <> "Quotation", 'SOPInvoiceCreditLine'[LineTotalValueGBP] * -1
, CreditType = "Invoice" && ReturnTypeName <> "Quotation", 'SOPInvoiceCreditLine'[LineTotalValueGBP]
, BLANK()
)
And after that create the below measure:
Sales Value =
Var selectedCurrency = SELECTEDVALUE('DIM: Currency Exchange'[Currency])
Var currencyExchange = SELECTEDVALUE('DIM: Live Currency Exchange'[USD per unit])
RETURN
IF(selectedCurrency = "GBP", [Total Value GBP], [Total Value GBP] * currencyExchange)
Hi Daniel,
First you need to create a New Column with the below formula:
Total Value GBP =
Var CreditType = RELATED('SOPInvoiceCreditType'[Name])
Var ReturnTypeName = RELATED('SOPOrderReturnType'[SOPOrderReturnTypeName])
RETURN
SWITCH(TRUE()
, CreditType = "Credit Note" && ReturnTypeName <> "Quotation", 'SOPInvoiceCreditLine'[LineTotalValueGBP] * -1
, CreditType = "Invoice" && ReturnTypeName <> "Quotation", 'SOPInvoiceCreditLine'[LineTotalValueGBP]
, BLANK()
)
And after that create the below measure:
Sales Value =
Var selectedCurrency = SELECTEDVALUE('DIM: Currency Exchange'[Currency])
Var currencyExchange = SELECTEDVALUE('DIM: Live Currency Exchange'[USD per unit])
RETURN
IF(selectedCurrency = "GBP", [Total Value GBP], [Total Value GBP] * currencyExchange)
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 27 | |
| 26 | |
| 22 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 45 | |
| 42 | |
| 41 | |
| 21 | |
| 18 |