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
Burak83_
Regular Visitor

COUNTIFS SUMIFS Power Pivot

Hi,

I am quite new ti this forum but what I see this forum is a treasure! I hope I can find an answer to my question as well!

I am trying to solve my problem in power pivot by writing a measure; I have achieved to solve my problem actually using excel function but I want to solve it using dax and measure

In this data, there are years where problem occurred, event descriptions and finally lost hours.
As a rule, to call an event as a cause;

  • Same event should happen 4 times or more in that year. In this case, total lost hours might be less than 8 hours
  • Same event might happen less than 4 times in that year. In this case, total lost hours should be more than 8 hours
  • Cause column is what I try to achive. I have achived by using following excel formula 
  • =IF(COUNTIFS(C:C,'UDT Analysis.xlsx'!#REF!,F:F,'UDT Analysis.xlsx'!#REF!)>3,"Yes",IF(SUMIFS(D:D,C:C,'UDT Analysis.xlsx'!#REF!,F:F,'UDT Analysis.xlsx'!#REF!)>7,"Yes","No"))

I will be so glad if you could help me to create a dax measure look similar to my excel formula. Thanks a lot for help and comments!

PlantDepartmentDescription  Lost hoursLost TonsYearQuarterMonthMonth NameWeekCause
SRIProductionLow Pressure Pump A2,6221202225May21No
SRIProductionBroken Chain Drive B2,1182202225May21No
SRIProductionBroken Chain Drive A0,868202225May20No
SRIProductionBroken Chain Drive B1,5130202225May20No
SRIProductionA1234TT0,974202225May20No
SRIProductionA1234TT0,14202225May20No
SRIProductionB758PT0,642202225May20No
SRIProductionB758PT0,14202225May20No
SRIProductionSDT0,323202225May20No
SRIMaintenanceSDT0,426202225May20No
SRIProductionBroken Roller0,217202225May20No
SRIProductionBroken Pump A2148202225May20No
SRIProductionBroken Pump A0,429202225May20No
SRIProductionGrinder B dwon189202225May20No
SRIProductionDowntime 0,213202225May20No
SRIMaintenanceDowntime 0,19202225May20No
SRIProductionGrinder B dwon03202225May20No
SRIProductionB758PT0,329202225May20No
SRIProductionStart up after downtime0,215202225May20No
SRIProductionLow Temperature Heater A1,4122202225May20No
SRIOtherSdt17,11,265202225May20Yes
SRIProductionLow Temperature Heater A02202225May20No
SRIProductionBroken Roller0,649202225May20No
SRIOtherSdt241,775202225May20Yes
SRIProductionBroken Bolt Pump A03202225May20No
SRIProductionBroken Bolt Pump A1,6138202225May20No
SRIProductionValve problem 0,112202225May20No
SRIOtherValve problem 0,110202225May20No
SRIOtherSDT16,71,234202225May20Yes
SRIMaintenanceBroken Bolt Pump A185202225May20No
SRIProductionA1234TT03202225May20No
SRIProductionTurbine failure0,324202225May20No
SRIProductionStart up after downtime1,191202225May20No
SRIProductionTurbine failure0,763202225May19No
SRIOtherNo power1,195202225May19No
SRIOtherNo power0,978202225May19No

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Burak83_ 
Please refer to sample file with the solution https://www.dropbox.com/t/S2iOGgF60q6tRzxL

1.png

Cause (Calculated) = 
VAR CaseYearTable = CALCULATETABLE ( Incidents, ALLEXCEPT ( Incidents, Incidents[Department],Incidents[Description], Incidents[Year] ) )
VAR AnnualOccurrences = COUNTROWS ( CaseYearTable )
VAR TotalLostHours = Incidents[Lost hours]
RETURN
    IF ( AnnualOccurrences >= 4 || TotalLostHours >= 8, "Yes", "No" )

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Burak83_ 
Please refer to sample file with the solution https://www.dropbox.com/t/S2iOGgF60q6tRzxL

1.png

Cause (Calculated) = 
VAR CaseYearTable = CALCULATETABLE ( Incidents, ALLEXCEPT ( Incidents, Incidents[Department],Incidents[Description], Incidents[Year] ) )
VAR AnnualOccurrences = COUNTROWS ( CaseYearTable )
VAR TotalLostHours = Incidents[Lost hours]
RETURN
    IF ( AnnualOccurrences >= 4 || TotalLostHours >= 8, "Yes", "No" )

Hi TamerJ 

Thanks for the solution this is exactly what I have asked for!! I have tried to solve this problem only with countrows or countx but it did not help me. I see that it requires extensive programming!

Greg_Deckler
Community Champion
Community Champion

@Burak83_ Check out the COUNTIF equivalents here: (1) CO-CU Excel to DAX Translation - Microsoft Power BI Community



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

Thanks for the link!

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.