Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I'm not able to optimize this measure. I'm new to Power BI DAX. Kindly suggest me a way to run this DAX faster.
If I am wrong, please suggest me any other alternative way to achieve the below DAX
DAX Measure:
Measure name =
SUMX (
SUMMARIZE (table_name',
table_name'[Col1],table_name'[Col2],table_name'[col3],table_name'[col4],table_name'[col5],
"result",
CALCULATE (
DISTINCTCOUNTNOBLANK ( table_name'[col1] ),
FILTER (
table_name',
SUM ( table_name'[Counter] ) = 1
)
)
),
[result]
)
@tamerj1 @johnt75 @Greg_Deckler -
I have created a temporary column using concat and counter column in the dataset.
temp_column = table_name[col1], table_name[col2]. table_name[col3], table_name[col4], table_name[col5]
Counter = 1 if the couter sum = 1 else 0
And I updated this DAX.
CALCULATE(
DISTINCTCOUNTNOBLANK ( TableName [Temp_column] ),
KEEPFILTERS ( tableName [Counter] = 1 )
)
Still, I'm facing the issue. The value is not matching. DAX is really difficult, please help me on this.
Please try
MeasureName =
SUMX (
SUMMARIZE (
FILTER ( table_name, table_name[Counter] = 1 ),
table_name[Col1],
table_name[Col2],
table_name[col3],
table_name[col4],
table_name[col5],
"result", COUNTROWS ( VALUES ( table_name[col1] ) )
),
[result]
)
Please try
MeasureName =
SUMX (
FILTER (
SUMMARIZE (
table_name,
table_name[Col1],
table_name[Col2],
table_name[col3],
table_name[col4],
table_name[col5],
"@Result", COUNTROWS ( VALUES ( table_name[col1] ) ),
"@Counter", SUM ( table_name[Counter] )
),
[@Conter] = 1
),
[@Result]
)
Hi @tamerj1 - I'm getting the value now. It loads much faster. But still we have more granularity, hence it is not loading in the matrix. It takes much time
@rishari
Try
MeasureName =
SUMX (
SUMMARIZE (
table_name,
table_name[Col1],
table_name[Col2],
table_name[col3],
table_name[col4],
table_name[col5],
"@Result", COUNTROWS ( VALUES ( table_name[col1] ) ),
"@Counter", SUM ( table_name[Counter] )
),
IF ( [@Conter] = 1, [@Result] )
)
Its not best practice to use SUMMARIZE to add calculated columns, its better to use ADDCOLUMNS, e.g.
MyMeasure =
SUMX (
ADDCOLUMNS (
SUMMARIZE (
'table_name',
'table_name'[Col1],
'table_name'[Col2],
'table_name'[col3],
'table_name'[col4],
'table_name'[col5]
),
"result",
CALCULATE (
DISTINCTCOUNTNOBLANK ( 'table_name'[col1] ),
FILTER ( 'table_name', SUM ( 'table_name'[Counter] ) = 1 )
)
),
[result]
)
This will return a single value, its just an optimized version of your code.
@rishari Can you post sample data so can test and optimize.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
38 | |
26 | |
20 | |
15 | |
8 |
User | Count |
---|---|
69 | |
47 | |
46 | |
20 | |
16 |