Forum Discussion
Anonymous
2 years agoNot applicable
Optimising DAX consolidated by multiple FACT tables
Hi all,
Following my question on the other fourm (Creating Revenue Measure using 2 Fact Tables (Diff... - Microsoft Fabric Community) I've managed to create a query which works. However, following inclusion of more than 4 reporting months I get an error that the visual has exceeded the available resource.
I Don't have any familarity with optimising DAX (not at this level) and was wondering how best to optimise the below code. Any help would be appriciated.
Revenue =
VAR AsatDate = MAX('As At Date'[Date]) + MAX('Time Table'[Time])
VAR CurrentDateInContext = SELECTEDVALUE('As At Date'[Date])
VAR PreviousDateInContext =
CALCULATE(
MAX('As At Date'[Date]),
ALLSELECTED('As At Date'),
KEEPFILTERS('As At Date'[Date] < CurrentDateInContext))
VAR test = CALCULATETABLE(SUMMARIZE(fact_opportunity_line_ledger,
fact_opportunity_line_ledger[Opportunity Line Item Id],
fact_opportunity_line_ledger[Stage Change],
fact_opportunity_line_ledger[Created Date/Time]),
fact_opportunity_ledger[Created DateTime] <= CurrentDateInContext)
var LineID = SELECTCOLUMNS(FILTER(
Index(1,
test,
Orderby(fact_opportunity_line_ledger[Created Date/Time],DESC),
PARTITIONBY(fact_opportunity_line_ledger[Opportunity Line Item Id])),
fact_opportunity_line_ledger[Stage Change] in {"Closed Won","Won"}),
"Line ID",fact_opportunity_line_ledger[Opportunity Line Item Id])
VAR OpID = CALCULATETABLE(VALUES(fact_opportunity_ledger[Opportunity Id]),
'fact_opportunity_ledger'[Com] = "",
'fact_opportunity_ledger'[Stage] = "Closed Won",
'fact_opportunity_ledger'[Validation Stage] = "Completed",
'fact_opportunity_ledger'[Created DateTime] >= PreviousDateInContext,
'fact_opportunity_ledger'[Created DateTime] < CurrentDateInContext)
VAR TCV = CALCULATE([Total Value (Date Reporting)],
LineID,
OpID
)
Return TCV
Thanks for any help provided.
1 Reply
- AnonymousNot applicable
Hi Anonymous ,
Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng