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

Countif formula or table

Hi,

 

This countif or the DAX version of it is my kryptonite for sure...

I have a task that's really easy to do in Excel and I'm pretty sure can be done in Power BI but I can't figure it out how.

I have a dataset like this:

Screenshot_1.png

 

What I want to do is to count the days where the sum of the spent_hours for a given site is higher than a preset formula (sum of all hours for that site for the week and divided by 14).

 

So for example for site 1 the value I want to compare to is 0,382643 (sum of all hours for week29 divided by 14) and the end result I want to see is 2 because on days 09.11. and 09.12. the sum of spent_hours are higher than the one I've calculated.

 

Is there a way to do this in a DAX formula? Or should I add a new table that calculates the daily spent_hours (so takes out the report_type column)? Or is there a better method? All ideas are welcome. 🙂

 

(I don't know if it's important but country, cluster, week and site are all in slicers.)

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Sounds like you want to use SUMMARIZE to summarize your data and then COUNTX with a FILTER to filter it down to just what you want.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Sounds like you want to use SUMMARIZE to summarize your data and then COUNTX with a FILTER to filter it down to just what you want.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank, this seems to be working!

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.