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
FabianB
Frequent Visitor

DAX - Count all rows from a dimension table with values below a max in a fact table

Hi,
 
I am trying to develop a DAX measure.
I have a dimension table (dim_machines) that contains a name column.
I have a fact table (machine_measurements), linked to the dimension table by this name column.
The fact table contains a power column and a timestamp with many power values for the different machines at different times.
 
I am now trying to design a measure that counts all machines that never have power values > 20.
 
here is what I tried so far:
InactiveCount =
 CALCULATE(COUNT(dim_machines[name]),FILTER(VALUES(dim_machines[name]),MAX(machine_measurements[power])<20))
 
The measure gives me a blank value. I think what is happening is that it is calculating the MAX value for the whole fact table instead of calculating it for each machine separately.
Can anyone give me a hint on how to solve this?
 
Many thanks!
1 ACCEPTED SOLUTION
ADPowerBI1
Responsive Resident
Responsive Resident

Count Machines < 20 =
COUNTROWS(
FILTER(dim_machines,
NOT(COUNTROWS(FILTER(machine_measurements, machine_measurements[power] > 20 && machine_measurements[name] = dim_machines[name])) > 0)
)
)

 

Hey could you try this and let me know if it works? Thanks! 🙂 

View solution in original post

3 REPLIES 3
FabianB
Frequent Visitor

Works like a charm. Thank you so much!

You're very welcome! Glad i could help!

ADPowerBI1
Responsive Resident
Responsive Resident

Count Machines < 20 =
COUNTROWS(
FILTER(dim_machines,
NOT(COUNTROWS(FILTER(machine_measurements, machine_measurements[power] > 20 && machine_measurements[name] = dim_machines[name])) > 0)
)
)

 

Hey could you try this and let me know if it works? Thanks! 🙂 

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.