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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MikeKKK
Frequent Visitor

Classic workspace Usage Metric - Trend View calculation

Happy New Year everyone!

 

I need a help on customised Power BI usage metric report.

 

I am using live connection to Usage Metrics dataset (classic workspace)for my customized usage report, and I would like to have "View Trend" (it is only available in new workspace usage metric dataset.) 

 

MikeKKK_0-1641346763759.png

The view trend reflects view count changes over time. It compares the first half of the selected time period with the second half. 

 

Thus, I created a measure as below:

 

View Trend =
VAR StartDate = MIN(Dates[Date])
VAR EndDate = MAX(Dates[Date])
VAR PeriodHalfDaysCount = INT((MAX(Dates[Date])-MIN(Dates[Date]))/2)
VAR MidDate = StartDate+PeriodHalfDaysCount
VAR FirstHalfView = CALCULATE([ViewsCount], DATESBETWEEN(Dates[Date],StartDate,MidDate))
VAR SecondHalfView = CALCULATE([ViewsCount], DATESBETWEEN(Dates[Date],MidDate+1,Enddate))

RETURN DIVIDE (SecondHalfView-FirstHalfView,FirstHalfView)
 
NOTE: [ViewsCount] is the predefined measure in Usage Metrics dataset.
 
This measure returns correct value but the calculation is taking extremely long time.   It is in tens of second while other predefined measures takes less than 1 seconds.
 
Am I doing the right thing here? Is there anything wrong with my measure? 

 

3 REPLIES 3
v-chenwuz-msft
Community Support
Community Support

Hi @MikeKKK ,

 

I recommend you to check the startdate and enddate of each report if they are all the same. Because the relationship between 'Date' table and other report table is one to many and the cross filter direction is single.

 

Then in your code, maybe the following code is better.

VAR FirstHalfView = CALCULATE([ViewsCount], 'Date'[Date]<=MidDate)
VAR SecondHalfView = CALCULATE([ViewsCount], 'Date'[Date]>MidDate)
 
For more methods of optimisation, please refer to the following article.
 
Or you can use an external tool, DAX Studio, to check the performance of dax.


Best Regards

Community Support Team _ chenwu zhu

 

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

amitchandak
Super User
Super User

@MikeKKK  , Try with this change

 

View Trend =
VAR StartDate = MINX(allselected(Dates) ,Dates[Date])
VAR EndDate = MAXX(allselected(Dates) ,Dates[Date])
VAR PeriodHalfDaysCount = INT((MAX(Dates[Date])-MIN(Dates[Date]))/2)
VAR MidDate = StartDate+PeriodHalfDaysCount
VAR FirstHalfView = CALCULATE([ViewsCount], DATESBETWEEN(Dates[Date],StartDate,MidDate))
VAR SecondHalfView = CALCULATE([ViewsCount], DATESBETWEEN(Dates[Date],MidDate+1,Enddate))

RETURN DIVIDE (SecondHalfView-FirstHalfView,FirstHalfView)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak   I can see you have changed the Variable StartDate and EndDate , how does this help?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.