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

@ 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

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")

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

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)

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

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
Super User
Super User

@jmateu88 COUNTIF equivalent is COUNTX(FILTER(...),...) CO-CU Excel to DAX Translation - Microsoft Power BI Community


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

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.