Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello,
I have two tables - Country and Language - as follows:
The relationship is as below on Country[CountryID] and Language[CID]
I would like to list the number of countries for each language .
I have a simple measure of the count of countries as follows:
But if I add it to a table, this is the result. It shows the same value across all languages:
The desired result I want is this one:
I can use CALCULATE as follows to get the correct value for each language, but then I have to specify the language in the filter:
Solved! Go to Solution.
Hi @Mirithu
Try the below measure.
Measure =
VAR _X =
SUMMARIZE (
Languages,
Languages[Language],
"Count", CALCULATE ( COUNT ( Country[Country] ) )
)
RETURN
SUMX ( _x, [Count] )
Thanks
Hari
You can create a measure like
Num countries per language =
CALCULATE (
COUNTROWS ( Country ),
CROSSFILTER ( Country[Country ID], Language[CID], BOTH )
)
You would not use the Country table at all to get the desired result.
Pull Language from the Language table on to a visual. Then drag CID on to the visual and change the aggregation to COUNT
Hi @Mirithu
Try the below measure.
Measure =
VAR _X =
SUMMARIZE (
Languages,
Languages[Language],
"Count", CALCULATE ( COUNT ( Country[Country] ) )
)
RETURN
SUMX ( _x, [Count] )
Thanks
Hari
Thank you @Hariharan_R . The measure works perfectly.
If you do not mind I would like to probe futher into it.
I noticed that you used SUMMARIZE in the variable. If I take the SUMMARIZE only and put in a table, I get the correct result.
But if I use SUMMARIZECOLUMNS as below, the result is wrong - same number for all rows. Even if I remove the CALCULATE, the result is still wrong.
Does SUMMARIZECOLUMNS ignore the current filter like CALCULATE does?
And how would you get the correct result using SUMMARIZECOLUMNS?
User | Count |
---|---|
84 | |
76 | |
72 | |
47 | |
37 |
User | Count |
---|---|
111 | |
56 | |
51 | |
42 | |
42 |