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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Bullpro_
Frequent Visitor

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 @Bullpro_ 

please try

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

View solution in original post

3 REPLIES 3
Bullpro_
Frequent Visitor

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 🙂 

@Bullpro_ 
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 @Bullpro_ 

please try

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors