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
onajourney
Frequent Visitor

Slow Dax with 9M rows

I am building a dashboard to get the counts of active employees on a specific date. This has come with quite a few challenges. The original data set has 400K rows. Here is the look of the test data:

 

onajourney_1-1602778188243.png

 

First, the user can get the breakdown by 13 different categories in two columns. I had to unpivot the columns for this which created 9 million rows. To get the second dynamic slicer,  I had to copy the query and keep just the unpivoted rows and have another table with 9 million rows and have a many to many relationship on the index like below. I had to copy the columns as the user can also use the slicer if they want to only see counts for a specific state. 

 

onajourney_0-1602777885917.png

I have a date text filter with a measure to get the active employees using: 

 
 
 
 
 
 
 


Show or Hide =
VAR SelectedDate = IF(SELECTEDVALUE('As of Date'[Date]) = "Today", TODAY(), DATEVALUE(SELECTEDVALUE('As of Date'[Date])))
RETURN
IF (SelectedDate >= MIN(FirstDate) && SelectedDate <= MAX(LastDate),"Show","Hide")

This is my measure to get the counts of the active employees at that date 

Sum Filter 2 =
VAR tmptable = FILTER(Sheet 1, [Choose Show or Hide] = "Show" && 'Sheet1'[Status] = "Active")
return
COUNTAX(tmptable, 'sheet1'[Emp ID])
 
 
My questions are: 
  • Is there a better way to model the data to make the dax faster? I tried to do 1 table of my base rows of 400K and 2 tables of 9M, but I wasnt able to put the unpivoted tables in the matrix because there was no relationship. 
  • Is there a better way to write the dax? Is Calculate with filters or Keep filters faster?
  • Is there a way to get the date filter to update other slicers? For instance, the company may be inactive on 9/1/20, but they are still listed in the slicer. If I click on it, it shows 0 headcount, but I would like to remove the ability to click on it.

Thank you! I appreciate the time. 

3 REPLIES 3
PaulDBrown
Community Champion
Community Champion

@onajourney 

When you say you have unpivoted a column, which column is it? (Is the table you posted the result after unpivoting or before?)

you should also create a date table with continuous dates covering the range of dates in you model.

can you share some sample (non-condidential) data? 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown 

 

https://www.dropbox.com/s/rxy2scwedp4zfv0/test%20data.pbix?dl=0


I created this test file that is the overall picture of my dashboard. Let me know if you are unable to download.

 

Right now, the date measure isn't working, but the logic is at any date, they can see the active count of employees by the detail they choose. In my dashboard, there are 13 columns unpivoted. All of the ones that the user  can choose to see the level of detail of. 

 

Thank you!

onajourney
Frequent Visitor

This is the look of the temp dashboard with drop down slicers. It does not include the date slicer, but that is a crucial piece to my real dashboard. 

onajourney_0-1602779165183.png

 

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.