Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
JohnnyDax2
New Member

DAX Performance issue FILTER

Hi everyone,

 

I'm experiencing a performance issue with a dataset.

The use case is to count to number of distinct store that are active.

I used to do DISTINCTCOUNT(Sales[Store_key])

Unfortunatly some store have several store_key because of a specific business context.

Therefore when i display them with the "Store Name" from the dimension "Store" it counted 2 instead of 1

 

So i changed the formula for this :

 

# Active Stores = 
VAR _StoreList = FILTER(VALUES(Store[Store Name]),[Sum of Sales]>0)

return countrows(_StoreList)

 

And this seems to work at first sight, but if i filter the "Store" table and at the same time create a table with the [Store Name] displayed it will not compute, it's just endlessly load and fail at some point.

If i put another dimension (like the day) it will work tho and fast.

 

Something more strange is that it kind of work on the main dataset (where we develop our measure) on the desktop client. But if i try the same test on a side report, connected to the dataset it will always fails.

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @JohnnyDax2 ,

You can try the following measure:

Flag =
var _table=
SUMMARIZE('Table','Table'[Store],"Sum",SUMX(FILTER(ALL('Table'),'Table'[Store]=EARLIER('Table'[Store])),[Sales]))
var _select=
SELECTCOLUMNS(FILTER(_table,[Sum]>0),"1",[Store])
return
CALCULATE(
    DISTINCTCOUNT([Store_key]),FILTER(ALL('Table'),'Table'[Store] in _select))

Result:

vyangliumsft_0-1669878755941.png

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

In your last two sentences, I'm not quite sure what you mean by whether the expected result is represented in the form of a picture.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors