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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Count number on values (which are measure) in a table

I have a table which is the monthly average of a group of data, and at the same time is the hourly average of that month.

MonthHourAve_soure1Measure_1
Jan0

-5

 
Jan1-5 
Jan2-5 
Jan3110.2%
Jan4571.8%
Jan51403.6%
Jan6763.2%
Jan7181.1%
Jan8-5 
Jan9-5 
Jan10-5 

And I would like to add a column which count each value in my Measure_1 column in this table.

Measure_2 = 
CALCULATE(
    COUNTAX('Fact Table_TIME', [Measure_1]),
    FILTER('Fact Table_TIME', [Hour])
)

Because what I am having is the count of values of the raw data which I use it to construct this average table.

What I have:


MonthHourAve_soure1Measure_1Measure_2
Jan0

-5

  
Jan1-5  
Jan2-5  
Jan3110.2%

1

Jan4571.8%2
Jan51403.6%2
Jan6763.2%2
Jan7181.1%2
Jan8-5  
Jan9-5  
Jan10-5  

I do not know why I am having this result, but what I want it is :

MonthHourAve_soure1Measure_1Measure_2
Jan0

-5

  
Jan1-5  
Jan2-5  
Jan3110.2%

1

Jan4571.8%1
Jan51403.6%1
Jan6763.2%1
Jan7181.1%1
Jan8-5  
Jan9-5  
Jan10-5  

So the total count will be 5. 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

please try

Measure_2 =
COUNX ( SUMMARIZE ( 'Fact Table_TIME', [Month], [Hour] ), [Measure_1] )

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I couldn't put the filter [Month], because it is in another fact table “Fact Table_DATE", and I saw it is not necessary to put [Month] in this case.
However, may I ask you two questions @tamerj1:
1. If I want to add a filter [Month] from another fact table, how I can add it ? (just for knowledge) 
2. Can you explain why the function COUNTX and SUMMArize works well in this case? 

And thanks for the solution 🙂 

@Anonymous 
I guess the table names that you are using are somehow confusing. My understanding that both 'Fact Table_DATE & Fact Table_TIME' are actually dim tables that are filtering a fact table (Let's call 'Fact Table'). So you can do

Measure_2 =
COUNTX (
    SUMMARIZE ( 'Fact Table', 'Fact Table_DATE'[Month], 'Fact Table_TIME'[Hour] ),
    [Measure_1]
)

Summarizing with the right columns is required to achieve the correct granularity at which we want to the measure to be evaluated. Iterating this table will guarantee that the outcome of the evaluation of the measure matches the evaluation at the visual row level. While iteration over the entire table row by row will result in a diffirent evaluation of the measure.

tamerj1
Super User
Super User

Hi @Anonymous 

please try

Measure_2 =
COUNX ( SUMMARIZE ( 'Fact Table_TIME', [Month], [Hour] ), [Measure_1] )

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.