Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hey guys, I am having processing problems in a dax query below:
It actually improved performance, but it doesn't produce the same expected result, I believe I have to maintain the same table filter context in a way that improves performance.
but thanks for the suggestion
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:
@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...
Hi @MarcosVME
Based on what you've posted, I would recommend turning vfilter into a column filter within the CALCULATE expression directly.
Something like this:
FLEX_METRICA_CALCULO_MERCADOMARCA_AREA_VISITADA =
CALCULATE (
[FLEX_METRICA_CALCULO_MERCADO_AREA_VISITADA],
USERELATIONSHIP ( D_MARCA[MERCADO], IM_D_MERCADO_FRANQUIA[MERCADO] ),
KEEPFILTERS ( NOT ISBLANK ( VEEVA_D_FORCA_DE_VENDAS[COD_SETOR] ) )
)
Generally performance is better with filters on columns rather than tables, and use KEEPFILTERS if the filter needs to intersect with the current filter context.
Does the above measure improve performance and still produce expected results?
Regards
User | Count |
---|---|
25 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
30 | |
13 | |
11 | |
9 | |
6 |