Forum Discussion
Any alternative to using Filter for performance
- 2 years ago
I will mark this as the solution if anything better comes up will change .Thank you Daniel29195 for your help.
MANAGER= VAR TABLE_VAR = CALCULATETABLE ( VALUES ( DIMENSION_TABLE ), DIMENSION_TABLE[DESCRIPTION] = "MANAGER" ) VAR MAX_VAR = MAXX ( FILTER ( TABLE_VAR, FACT_TABLE[DATE_OF_SALE] >= [STARTDATE_] && FACT_TABLE[DATE_OF_SALE] <= [ENDDATE_] && FACT_TABLE [EMPLOYEEID_] = [EMPLOYEE_ID] ), [Value] ) RETURN MAX_VAR
hello North_Man
it seems that you are working with sc2 .
the problem is that the table should have a surrogate key which is unique, and this way you wouldnt need all thi code,
you would only need related function ( since both tables would be linked on the surrogate key ) .
can you try this way :
DIMENSION_TABLE[Value]
check image below.
calculate will invoke context transition from the fact, which would be expensive .
give it try, and tell me it would be more performat.
best regards
Hi Daniel Unfortunately the code you provided it's still to expensive . Any other ideas as I cannot implement surrogate keys either .Thank You
- Daniel291952 years agoCommunity Champion
- North_Man2 years agoFrequent Visitor
Hi Daniel
I came up with the below code using your suggestion which is working much better. If you or anyone else has any ideas to make it even more efficient please let me know.
MANAGER=
VAR TABLE_VAR =
CALCULATETABLE ( VALUES ( DIMENSION_TABLE ), DIMENSION_TABLE[DESCRIPTION] = "MANAGER" )
VAR MAX_VAR =
MAXX (
FILTER (
TABLE_VAR,
FACT_TABLE[DATE_OF_SALE] >= [STARTDATE_]
&& FACT_TABLE[DATE_OF_SALE] <= [ENDDATE_]
&& FACT_TABLE [EMPLOYEEID_] = [EMPLOYEE_ID]
),
[Value]
)
RETURN
MAX_VAR
- North_Man2 years agoFrequent Visitor
I will mark this as the solution if anything better comes up will change .Thank you Daniel29195 for your help.
MANAGER= VAR TABLE_VAR = CALCULATETABLE ( VALUES ( DIMENSION_TABLE ), DIMENSION_TABLE[DESCRIPTION] = "MANAGER" ) VAR MAX_VAR = MAXX ( FILTER ( TABLE_VAR, FACT_TABLE[DATE_OF_SALE] >= [STARTDATE_] && FACT_TABLE[DATE_OF_SALE] <= [ENDDATE_] && FACT_TABLE [EMPLOYEEID_] = [EMPLOYEE_ID] ), [Value] ) RETURN MAX_VAR