Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
BlastS
Helper I
Helper I

Count Number test[Column(Failures)] = 1 when column X last row = 0.2

I am new to dax formulas i already tryend some things but nothing is realy working to get this result, actualy i got this columns for use to this calculation:

 

Index;Failures; ColumnX; 

1           0              0

2           0              0.2

3           1               0

4           0               0

5           1               0

6           0              0.2

7           1               0

...

I want to count all failures = 1 when columnX last row = 0.2. Which means when its one it needs to check if last row of column X is 0.2 to count otherwise dont count.

 

This is my try so far : 

Count of Failures =CALCULATE(COUNTAX(TableA,TableA[Failures]) = 1, LOOKUPVALUE(TableA[ColumnX)],TableA[Index],TableA[Index]-1),TableA[ColumnX])

 

ERROR RETURNED:

A LOOKUPVALUE function was used in a True / False expression used as a table filter expression. This is not allowed.

 

OUTPUT should BE:

The output of count number of failures = 1 should be: 2

 

How can i achieve this in powerbI?

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Try something like:

 

Count of Failures = 
VAR __table = ADDCOLUMNS('Table',"__failure",IF([Failures]=1 && MAXX(FILTER('Table',[Index]=EARLIER([Index])-1),[ColumnX])=.2,1,0)) 
RETURN SUMX(__table,[__failure])


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

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

Try something like:

 

Count of Failures = 
VAR __table = ADDCOLUMNS('Table',"__failure",IF([Failures]=1 && MAXX(FILTER('Table',[Index]=EARLIER([Index])-1),[ColumnX])=.2,1,0)) 
RETURN SUMX(__table,[__failure])


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...
Anonymous
Not applicable

Count ASD =
VAR __table = ADDCOLUMNS(Geradores,"__failure",IF([Failure Event]=1 && MAXX(FILTER('Geradores',[Index]=EARLIER([Index])-1),[columnX)])=.2,1,0))
RETURN SUMX(__table,[__failure])

 

i tryed this and its returning some insane values i cant understand dwhy, it should return only 7 instead of 135.

 

Count all 1 failures events that has columnx index-1 = 0.2  what could possibly be wrong ? 

Not sure, seems to work for me. See Page 10 and Table 15 in attached file.


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

I manipulate a litle bit your solution to my case and it worked, thanks buddy.

My problem was the index, since i got for example 8 datasets the index was the same for each dataset so i create a new one for all and it work fine.

Solution: 

FailuresCount = IF([Failure])=1 && MAXX(FILTER('Table',[Index]=EARLIER([Index])-1),[ColumnX)])=.2,1,0)

@BlastS - Awesome! Glad you got it!



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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors