Forum Discussion
Problem with dax query time
Thanks for testing that out and sorry it didn't produce the same result.
Could you post a picture of the data model diagram & the definition of the measure [FLEX_METRICA_CALCULO_MERCADO_AREA_VISITADA]?
I was making some standard assumptions about the data model but there could be something specific to consider with your model.
This is my data modeling below:
And this is my full dax script:
- OwenAuger2 years agoSuper User
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
- MarcosVME2 years agoNew Member
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...
CALCULATE(CALCULATE([FLEX_METRICA_CALCULO_MERCADOMARCA_AREA_VISITADA],USERELATIONSHIP(D_MARCA[MERCADO],IM_D_MERCADO_FRANQUIA[MERCADO])),CROSSJOIN(VEEVA_D_FORCA_DE_VENDAS, D_LINHA))- 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.