Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
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
I want to make average of users per month.
Count of users are distinct each month.
But I want my average should look like: for the first two months (173+308)/2 or for three months (173+308+382)/3.
The formula giving me the avg. of all the distinct users selected in a given period.
I tried something like this--
Average User Count by month = IF (
HASONEVALUE ( 'Talend_GA sessions'[Month] );
DISTINCTCOUNT ( 'public accounts_usersession'[user_id] );
DIVIDE(
AVERAGEX('public accounts_usersession';DISTINCTCOUNT('public accounts_usersession'[user_id]));
DISTINCTCOUNT('Talend_GA sessions'[Month])
)
)
Solved! Go to Solution.
@Anonymous
What about this one? ![]()
Average User Count by month =
IF (
HASONEVALUE ( 'Talend_GA sessions'[Month] ),
AVERAGEX (
FILTER (
ALLSELECTED ( 'Talend_GA sessions'[Month] ),
'Talend_GA sessions'[Month] <= SELECTEDVALUE ( 'Talend_GA sessions'[Month] )
),
CALCULATE ( DISTINCTCOUNT ( 'public accounts_usersession'[user_id] ) )
),
DIVIDE (
AVERAGEX (
ALL ( 'Talend_GA sessions'[Month] ),
CALCULATE ( DISTINCTCOUNT ( 'public accounts_usersession'[user_id] ) )
),
DISTINCTCOUNT ( 'Talend_GA sessions'[Month] )
)
)
@Anonymous
Try this please
Average User Count by month =
IF (
HASONEVALUE ( 'Talend_GA sessions'[Month] ),
AVERAGEX (
FILTER (
ALLSELECTED ( 'Talend_GA sessions'[Month] ),
'Talend_GA sessions'[Month] <= SELECTEDVALUE ( 'Talend_GA sessions'[Month] )
),
CALCULATE ( DISTINCTCOUNT ( 'public accounts_usersession'[user_id] ) )
),
DIVIDE (
AVERAGEX (
'public accounts_usersession',
DISTINCTCOUNT ( 'public accounts_usersession'[user_id] )
),
DISTINCTCOUNT ( 'Talend_GA sessions'[Month] )
)
)
Hi @Zubair_Muhammad,
Thank you for your solution. It's works great. But I have one more question why in the Total it showing the distinct count of whole year divided by 12.
It should show me the sum of all the values here in the table divided by 12.
Or, Am I missing something here ?
@Anonymous
Actually i didn't touch the second argument of IF.
Check this one. I just added CALCULATE highlighted in red font below
Average User Count by month =
IF (
HASONEVALUE ( 'Talend_GA sessions'[Month] ),
AVERAGEX (
FILTER (
ALLSELECTED ( 'Talend_GA sessions'[Month] ),
'Talend_GA sessions'[Month] <= SELECTEDVALUE ( 'Talend_GA sessions'[Month] )
),
CALCULATE ( DISTINCTCOUNT ( 'public accounts_usersession'[user_id] ) )
),
DIVIDE (
AVERAGEX (
'public accounts_usersession',
CALCULATE ( DISTINCTCOUNT ( 'public accounts_usersession'[user_id] ) )
),
DISTINCTCOUNT ( 'Talend_GA sessions'[Month] )
)
)
Now, I am getting some strange value in the total.
@Anonymous
What about this one? ![]()
Average User Count by month =
IF (
HASONEVALUE ( 'Talend_GA sessions'[Month] ),
AVERAGEX (
FILTER (
ALLSELECTED ( 'Talend_GA sessions'[Month] ),
'Talend_GA sessions'[Month] <= SELECTEDVALUE ( 'Talend_GA sessions'[Month] )
),
CALCULATE ( DISTINCTCOUNT ( 'public accounts_usersession'[user_id] ) )
),
DIVIDE (
AVERAGEX (
ALL ( 'Talend_GA sessions'[Month] ),
CALCULATE ( DISTINCTCOUNT ( 'public accounts_usersession'[user_id] ) )
),
DISTINCTCOUNT ( 'Talend_GA sessions'[Month] )
)
)
Now, It's still something strange. But no worries I can live with that. Thanks a lot for your help.
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.
| User | Count |
|---|---|
| 44 | |
| 43 | |
| 38 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 67 | |
| 66 | |
| 31 | |
| 28 | |
| 24 |