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
PowerrrBrrr
Helper III
Helper III

Measure to count the items from a table with some filter

Hi, I have below columns in two diffferent table and I would like to show count of no of machines which has 0 value for the latest date.

Table 1

Id                                 Machine
1                                MachineA
2                                MachineB
3                                MachineC

 

Table 2


 

Id                                Value                     Timestamp
1                        7                       2021-09-09
1                       4                       2021-09-15
1                       0                       2021-09-21
2                       6                       2021-09-09

 

Here I want count as 1 as latest date in the timestamp is 2021-09-21 where one machine is having value as 0. How can I create a measure for this.

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Here's a measure that can accomplish this:

 

MaxCount = 
var l = maxx('Table 2','Table 2'[Timestamp])
var c = CALCULATE(DISTINCTCOUNT('Table 2'[Id]),ALLSELECTED('Table 2'),'Table 2'[Timestamp]=l,'Table 2'[Value]=0)
return c

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Here's a measure that can accomplish this:

 

MaxCount = 
var l = maxx('Table 2','Table 2'[Timestamp])
var c = CALCULATE(DISTINCTCOUNT('Table 2'[Id]),ALLSELECTED('Table 2'),'Table 2'[Timestamp]=l,'Table 2'[Value]=0)
return c

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.