Forum Discussion
Anonymous
7 years agoNot applicable
Summarize function not including users with 0 values
I am working with data based on customers viewing a web page. I am trying to come up with a visual based on how many customers have viewed a web page based on groupings - I followed the article below...
- 7 years ago
Hi Anonymous
Create a new table
new table = UNION ( SUMMARIZE ( 'Page Views', 'Page Views'[user name], "count", VAR count_num = CALCULATE ( COUNT ( 'Page Views'[time stamp] ), ALLEXCEPT ( Customers, Customers[user name] ) ) RETURN IF ( count_num = 0, 0, count_num ) ), ADDCOLUMNS ( EXCEPT ( VALUES ( Customers[user name] ), VALUES ( 'Page Views'[user name] ) ), "count", 0 ) )Add calculated columns in this new table
range = SWITCH ( TRUE (), [count] = 0, "0", [count] <= 5 && [count] >= 1, "1~5", [count] <= 10 && [count] >= 6, "6~10" ) min = VAR s = IF ( [range] <> "0", VALUE ( FIND ( "~", [range], 1, 0 ) ) - 1 ) RETURN IF ( [range] = "0", "0", LEFT ( [range], s ) ) max = VAR e = IF ( [range] <> "0", VALUE ( LEN ( [range] ) ) - VALUE ( FIND ( "~", [range], 1, 0 ) ) ) RETURN IF ( [range] = "0", "0", RIGHT ( [range], e ) ) total.no = CALCULATE ( DISTINCTCOUNT ( 'new table'[user name] ), ALLEXCEPT ( 'new table', 'new table'[range] ) )Best Regards
MaggieCommunity Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-juanli-msft
7 years agoCommunity Support
Hi Anonymous
Create a new table
new table =
UNION (
SUMMARIZE (
'Page Views',
'Page Views'[user name],
"count",
VAR count_num =
CALCULATE (
COUNT ( 'Page Views'[time stamp] ),
ALLEXCEPT ( Customers, Customers[user name] )
)
RETURN
IF ( count_num = 0, 0, count_num )
),
ADDCOLUMNS (
EXCEPT ( VALUES ( Customers[user name] ), VALUES ( 'Page Views'[user name] ) ),
"count", 0
)
)
Add calculated columns in this new table
range =
SWITCH (
TRUE (),
[count] = 0, "0",
[count] <= 5
&& [count] >= 1, "1~5",
[count] <= 10
&& [count] >= 6, "6~10"
)
min =
VAR s =
IF ( [range] <> "0", VALUE ( FIND ( "~", [range], 1, 0 ) ) - 1 )
RETURN
IF ( [range] = "0", "0", LEFT ( [range], s ) )
max =
VAR e =
IF (
[range] <> "0",
VALUE ( LEN ( [range] ) ) - VALUE ( FIND ( "~", [range], 1, 0 ) )
)
RETURN
IF ( [range] = "0", "0", RIGHT ( [range], e ) )
total.no =
CALCULATE (
DISTINCTCOUNT ( 'new table'[user name] ),
ALLEXCEPT ( 'new table', 'new table'[range] )
)
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.