Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerBI - Calculate the number of occurance of a value in a column using calculated field

Tags:

powerbi

I am trying to calculate the number of times a value occurs in a column by using calculated field. Measure can do this a bit more easily, but measure limits my usage for creating other columns and the usages in the dashboards.

City

BOS

DTW

CLE

CLE

BOS

BOS

Expected Output:    

City   Total

BOS  3

CLE  2

DTW  1

Using the the option of Groupby in the query editor neglects the other columns which are on my data.

like image 321
Siddharth Thanga Mariappan Avatar asked Dec 03 '25 20:12

Siddharth Thanga Mariappan


1 Answers

If you want your output as its own table then you can do:

CityCount = SUMMARIZECOLUMNS(Cities[City], "Total", COUNT(Cities[City]))

If you want it as a calculated column:

Total = COUNTROWS(FILTER(Cities, Cities[City] = EARLIER(Cities[City])))

(Assuming your table name is Cities.)

like image 105
Alexis Olson Avatar answered Dec 06 '25 15:12

Alexis Olson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!