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
jmateu88
Helper I
Helper I

Mixing something like COUNTIFS with the min value for each case.

Hello,

I am trying to find the way to do in Power BI what I would do in Excel using COUNTIFS (for the first part of the message)
After this, a conditional with the minimum value (for the second part).

The purpose is to know which machines are being repaired and if not, when is the next maintenance (depending on the ranking).

 

For that, the first I consider (I may be wrong) is to get a DAX formula (similar to Excel COUNTIFS) to get if a machine is being repaired or not.

In excel would be something like this;

Screenshot_3.jpg

We can see in the 'column I' for each registers de amount of tasks being done for each machine.

 

Once we have this, I want to obtain another column (the good one)(in the example 'K'), where all machines in process are in 'Yes' and those machines which done ('C' in the example), only is shown the next one (the one with the minimum value in column 'H') too.

Explaining this in the opposite way, I do not want to see any of the machines in status 'Pending' unless that register has the minimum value in column 'H' and that machine has not any activity in process.

 

Finally, thank you for your grateful help! This might be easy if you have the clue but for me, it is getting too complicated.
Regards!



1 ACCEPTED SOLUTION

@jmateu88 PBIX is attached below signature. This is the column I created:

Column = 
  VAR __Machine = [Machine]
  VAR __Seq = MINX(FILTER('Table',[Machine] = __Machine),[Seq.no])
RETURN
  IF([Status] = "In process" || [Seq.no] = __Seq,1,0)


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...

View solution in original post

6 REPLIES 6
jmateu88
Helper I
Helper I

Thank you @Greg_Deckler . I already gave you a like in your other post. Very interesting the comparison.

However, I still have doubts about the way you use de filterexpression. I suppose that in filterexpression is where others machines (in the example) are filtered depending on the row?

Thanks in advance! I already tryied with FILTER but i did not find the way to use properly the filterexpression.

@jmateu88 Can you post your sample data as text and I can create a specific solution for it. Otherwise I'm likely to miss a paren or not account for a particular edge case. But, could be:

Column =
  VAR __Machine = [MachineID]
  VAR __Seq = MINX(FILTER('Table',[MachineID] = __Machine),[Sequential Number])
RETURN
  IF([Status] = "In process" || [Sequential Number] = __Seq,"Yes","No")


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...

Hello @Greg_Deckler ,

Here the data;

MachineStatusSeq.no
AIn process1
BIn process1
CPending1
AIn process2
BPending2
BPending3
CPending2
APending3
BPending4
CPending3
APending4
BPending5
APending5

 

Here trying in Power BI.
Screenshot_1.jpg

 

Thank you!!

@jmateu88 PBIX is attached below signature. This is the column I created:

Column = 
  VAR __Machine = [Machine]
  VAR __Seq = MINX(FILTER('Table',[Machine] = __Machine),[Seq.no])
RETURN
  IF([Status] = "In process" || [Seq.no] = __Seq,1,0)


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...

Woow @Greg_Deckler . That was amazing.

I learnt a lot with this simple and incredible expression. Thank you very much!

The solution is more than valid!

Greg_Deckler
Community Champion
Community Champion

@jmateu88 COUNTIF equivalent is COUNTX(FILTER(...),...) 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...

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.