Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi all!
I have an activity table with dates and user's operations. I need to calculate for a line chart (with timeline) a number for each date with unique user id-s on the previous 7 days.
I've created a DAX function over the datamodel with window function, but it's too slow. So I would like to replace it with a visual calculation formula where I put the date and userid fields to the line chart from the model.
What should be the formula then?
Hi @somogyitamas88 ,
May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.
Thank you.
Hi @somogyitamas88 ,
Thank you @FBergamaschi , @Kedar_Pande for your inputs.
I just wanted to check if the issue has been resolved on your end, or if you require any further assistance. Please feel free to let us know, we’re happy to help!
Thank you
7D Unique Users =
RANKX(
WINDOW(-6,0,ALLSELECTED(Date[Date]),ORDERBY(Date[Date])),
DISTINCTCOUNT(Activity[UserID]),
,
ASC
)
Date (X-axis), UserID (small multiples or legend), measure above (Y)
Hi @somogyitamas88,
I see the code was alreayd given to you so I will not go on that
My worry is that you realize than the visual calculation will give a different result than a measure on the first 6 days if you apply a filter to the dates in the report
Imagine you filter a single month, say November 2025. On 1st of nov 205 I assume you would like to see a number depending on the last 7 days of october. But that, with a visual calculation, is impossible
Just wanted you to be aware of this
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
Thank you.
Instead of window function could you try the formula below:
Active Users (7D) =
VAR EndDate = MAX ( 'DimDate'[Date] )
RETURN
CALCULATE(
DISTINCTCOUNT ( Activity[UserId] ),
DATESINPERIOD ( 'DimDate'[Date], EndDate, -7, DAY )
)
Unfortunately it's too slow.
This is my current one:
It's faster however with more 10-15 sec loading.
Hi,
You can use this below for visual calculation.
Hi, it only shows the distinct num of dates in the previous 7 days. (Mainly show 7, but when there are no activity on a day, its less).
X‑axis: put your Date (continuous, daily).
Y‑axis: any metric (you can even use a dummy measure like 1).
Details: add UserId (this is the key step).
With the visual selected, Home ▸ New calculation and paste:
For me Details accepts only measure (at least implicit one). So I can drag User ID nowhere.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 3 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 21 | |
| 14 | |
| 11 | |
| 6 | |
| 5 |