Forum Discussion
Problem with dax query time
MarcosVME - thanks for the extra detail on the model!
The relationships add a bit of complexity, but I think explain why my suggested measure wasn't working 🙂
Your original measure applied the expanded table VEEVA_D_FORCA_DE_VENDAS (first filtered to nonblank values of VEEVA_D_FORCA_DE_VENDAS[COD_SETOR] ) as a filter.
I believe the original performance issue is due to applying FILTER (an iterator) to VEEVA_D_FORCA_DE_VENDAS.
Here are a couple of options that I believe should improve performance and return the correct results (fingers crossed 🙂 )
Option 1:
Applies the nonblank filter in outer CALCULATE, then applies the expanded VEEVA_D_FORCA_DE_VENDAS table filter.
FLEX_METRICA_CALCULO_MERCADOMARCA_AREA_VISITADA =
CALCULATE (
CALCULATE (
[FLEX_METRICA_CALCULO_MERCADO_AREA_VISITADA],
USERELATIONSHIP ( D_MARCA[MERCADO], IM_D_MERCADO_FRANQUIA[MERCADO] ),
VEEVA_D_FORCA_DE_VENDAS
),
KEEPFILTERS ( NOT ISBLANK ( VEEVA_D_FORCA_DE_VENDAS[COD_SETOR] ) )
)
Option 2:
Applies the nonblank filter in outer CALCULATE, and in inner calculate uses SUMMARIZE to apply a filter on only column on 1-side of relationship with VEEVA_D_FORCA_DE_VENDAS (LINHA).
FLEX_METRICA_CALCULO_MERCADOMARCA_AREA_VISITADA =
CALCULATE (
CALCULATE (
[FLEX_METRICA_CALCULO_MERCADO_AREA_VISITADA],
USERELATIONSHIP ( D_MARCA[MERCADO], IM_D_MERCADO_FRANQUIA[MERCADO] ),
SUMMARIZE ( VEEVA_D_FORCA_DE_VENDAS, D_LINHA[LINHA] )
),
KEEPFILTERS ( NOT ISBLANK ( VEEVA_D_FORCA_DE_VENDAS[COD_SETOR] ) )
)
Do either of these produce the correct results with better performance?
Regards
Thanks for your great suggestions.
Option 1 worked and returned the same value, I even tried using crossjoin and it also worked, but it seems that the performance is still bad... in the model the DEMANDA_SETOR_BRICK table has 3 million rows and I believe that it is directly affecting performance due to the relations...
- OwenAuger2 years agoSuper User
Understood - thanks for the update.
I'm not sure I can help much more here - this probably requires more detailed inspection of the model and testing to resolve.