Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
have a table with this structure:
column1: Website_pageview_id (int column)
column2: created_at (date column)
column3: time (time column)
column4: Website_session_id
column5: pageview_url
so Website_session_id 17562 has 6 pages associated, each with a unique Website_pageview_id. calculating the minimum Website_pageview_id associated with 1 Website_session_id you get the first visited page by Website_session_id.
Using Dax Studio I'am able to calculate how many times a specific page was used / visited as the first page.
EVALUATE
VAR firstpage =
SELECTCOLUMNS (
ADDCOLUMNS (
SUMMARIZE (
website_sessions,
website_sessions[website_session_id]
),
"firstpagecode",
CALCULATE (
MINX (
website_sessions,
website_sessions[website_pageview_id]
)
)
),
[firstpagecode]
)
VAR filtersessions =
CALCULATETABLE (
website_sessions,
TREATAS (
firstpage,
website_sessions[website_pageview_id]
)
)
RETURN
GROUPBY (
filtersessions,
website_sessions[pageview_url],
"hits",
SUMX (
CURRENTGROUP (),
1
)
)
and i get this result:
On PowerBi desktop I built a measure from the query:
N times page visited 1st time =
VAR currentpagess = MAX(website_sessions[pageview_url])
VAR firstpage =
SELECTCOLUMNS (
ADDCOLUMNS (
SUMMARIZE (
website_sessions,
website_sessions[website_session_id]
),
"firstpagecode",
CALCULATE (
MINX (
website_sessions,
website_sessions[website_pageview_id]
)
)
),
[firstpagecode]
)
VAR filtersessions =
CALCULATETABLE (
website_sessions,
TREATAS (
firstpage,
website_sessions[website_pageview_id]
)
)
Var Result =
CALCULATE(
SUMX(
FILTER(filtersessions,
website_sessions[pageview_url] = currentpagess
)
, 1)
)
Var Result2 =
COUNTROWS( filtersessions )
Return
Result2
I get this result Using pageview_url as dimension (in the code before i can use result or result2 the final is always the same):
Knowing that
Can someone help me on this one.
i leave here the file if someone is interested
Download File
Solved! Go to Solution.
A typical scenario where you need ALL / VALUES, to ignore part of the filter context.
This should work:
N times page visited 1st time 2 =
VAR currentpagess = MAX(website_sessions[pageview_url])
VAR firstpage =
CALCULATETABLE (
SELECTCOLUMNS (
ADDCOLUMNS (
SUMMARIZE (
website_sessions,
website_sessions[website_session_id]
),
"firstpagecode",
CALCULATE (
MINX (
website_sessions,
website_sessions[website_pageview_id]
)
)
),
[firstpagecode]
),
ALL ( website_sessions ),
VALUES ( website_sessions[website_session_id] )
)
VAR filtersessions =
CALCULATETABLE (
website_sessions,
TREATAS (
firstpage,
website_sessions[website_pageview_id]
)
)
Var Result =
CALCULATE(
SUMX(
FILTER(filtersessions,
website_sessions[pageview_url] = currentpagess
)
, 1)
)
Var Result2 =
COUNTROWS( filtersessions )
Return
Result2You might need to replace ALL with something less strong, this depends on your requirements.
Enjoy DAX
A typical scenario where you need ALL / VALUES, to ignore part of the filter context.
This should work:
N times page visited 1st time 2 =
VAR currentpagess = MAX(website_sessions[pageview_url])
VAR firstpage =
CALCULATETABLE (
SELECTCOLUMNS (
ADDCOLUMNS (
SUMMARIZE (
website_sessions,
website_sessions[website_session_id]
),
"firstpagecode",
CALCULATE (
MINX (
website_sessions,
website_sessions[website_pageview_id]
)
)
),
[firstpagecode]
),
ALL ( website_sessions ),
VALUES ( website_sessions[website_session_id] )
)
VAR filtersessions =
CALCULATETABLE (
website_sessions,
TREATAS (
firstpage,
website_sessions[website_pageview_id]
)
)
Var Result =
CALCULATE(
SUMX(
FILTER(filtersessions,
website_sessions[pageview_url] = currentpagess
)
, 1)
)
Var Result2 =
COUNTROWS( filtersessions )
Return
Result2You might need to replace ALL with something less strong, this depends on your requirements.
Enjoy DAX
Hi @hperalta,
This is related with context, believe that there is an easier way to solve this. Create a column on your model that gives you the order of the pages so in this case I added the following column to my the model:
Page View Rank =
RANK (
DENSE,
ALL (
website_sessions[website_pageview_id],
website_sessions[website_session_id]
),
ORDERBY ( website_sessions[website_pageview_id], ASC ),
,
PARTITIONBY ( website_sessions[website_session_id] )
)
Now add the following measure:
Total Views first page =
COUNTROWS( FILTER(website_sessions, website_sessions[Page View Rank] = 1))
Result below and in attach file:
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsBom Dia M Felix,
Muito obrigado for your answer. you are indeed correct that is a viable solution to achieve the correct numbers.
i must admit that i was (still am) so focus in building the measure that did no look other solutions. And
in the end the countrows filter solution or calculate
agora sim =
CALCULATE(
COUNTROWS( mvf_website_pageviews ),
mvf_website_pageviews[Ranking] = 1
)is the same. actually a small change in the data model made a huge difference on the measure.
thanks for you idea and time spend.
ill still wait for another measure solution (if it arrives )... if i don't have any more answers I'll mark you answer as solution...
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 97 | |
| 74 | |
| 50 | |
| 47 | |
| 44 |