Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Mirithu
Helper II
Helper II

Of CALCULATE and filters

Hello,

I have two tables - Country and Language - as follows: 

tables.png

The relationship is as below on Country[CountryID] and Language[CID]

 

relatonship.png

I would like to list the number of countries for each language .

 

I have a simple measure of the count of countries as follows: 

CountryCnt = COUNT( Country[CountryID] )

 

But if I add it to a table, this is the result. It shows the same value across all languages:
wrong.png
The desired result I want is this one:

 

wanted.png

 

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:

 

CountryCnt English =
    CALCULATE (
    [CountryCnt],
    FILTER (
        'Language',
        'Language'[Lang] = "English"
    )
)
 
But how do I get the desired result for all languages as indicated?
1 ACCEPTED SOLUTION
Hariharan_R
Solution Sage
Solution Sage

Hi @Mirithu 

Try the below measure.

 

Measure =
VAR _X =
SUMMARIZE (
Languages,
Languages[Language],
"Count", CALCULATE ( COUNT ( Country[Country] ) )
)
RETURN
SUMX ( _x, [Count] )

 

Thanks

Hari

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

You can create a measure like

Num countries per language =
CALCULATE (
    COUNTROWS ( Country ),
    CROSSFILTER ( Country[Country ID], Language[CID], BOTH )
)
HotChilli
Community Champion
Community Champion

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

Hariharan_R
Solution Sage
Solution Sage

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.

 

SUMMARIZECOLUMNS(
    'Language'[Language],
    "Count", CALCULATE( COUNT( Country[Country] ) )
    )


Does SUMMARIZECOLUMNS ignore the current filter like CALCULATE does? 
And how would you get the correct result using SUMMARIZECOLUMNS?

 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.