Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
1.1k views
in Power BI by 4 4 11
I have one dataset contain global event's calender for several countries ..

Can you offer guidance on the method for counting occurrences for each country's data within the dataset by using dax ?

1 Answer

0 like 0 dislike
by 4 4 11
 
Best answer

This DAX expression for Count the number of occurrences of each country in a table using Power BI.

Count_Occurrences = COUNTROWS(FILTER('TABLE_NAME', 'TABLE_NAME'[COLUMN_NAME] = EARLIER('TABLE_NAME'[COLUMN_NAME])))

counts the number of occurrences of each country in the SELECTED table.

The COUNTROWS function counts the number of rows in a table.

The FILTER function filters a table based on a specified condition.

The EARLIER function returns the value of an expression that was evaluated in a previous context.

In this case, the FILTER function is filtering the table to only include rows where the Country column is equal to the current value of the Country column.

The EARLIER function is ensuring that the Country column is evaluated in the context of the current row.

Therefore, the expression will return the number of times that the current country appears in the table.

  • The expression can be used in a variety of ways. For example, it could be used to create a report that shows the number of each country. It could also be used to create a measure that calculates the average number per country.

If you don’t ask, the answer is always NO!
...