Forum Discussion
Count with specific conditions
- 8 years ago
Try this calculated column
Column = VAR PreviousDate = CALCULATE ( MAX ( EventLog[Date] ), FILTER ( ALLEXCEPT ( EventLog, EventLog[Machine] ), EventLog[Event] = "setUp" && EventLog[Date] < EARLIER ( EventLog[Date] ) ) ) VAR PreviousMaterial = CALCULATE ( FIRSTNONBLANK ( EventLog[Semi.Mat.No.], 1 ), FILTER ( ALLEXCEPT ( EventLog, EventLog[Machine] ), EventLog[Event] = "setUp" && EventLog[Date] = PreviousDate ) ) RETURN IF ( EventLog[Semi.Mat.No.] = PreviousMaterial, 0, 1 ) - 8 years ago
- 8 years ago
Hi Asim
Try this MEASURE... I am not sure if it will speed up things
Setup Count Measure = VAR mytable = ADDCOLUMNS ( Eventlog, "Asim", VAR PreviousDate = CALCULATE ( MAX ( EventLog[Date] ), FILTER ( ALLEXCEPT ( EventLog, EventLog[Machine] ), EventLog[Event] = "setup" && EventLog[Date] < EARLIER ( EventLog[Date] ) ) ) VAR PreviousMaterial = CALCULATE ( FIRSTNONBLANK ( EventLog[Semi.Mat.No.], 1 ), FILTER ( ALLEXCEPT ( EventLog, EventLog[Machine] ), EventLog[Event] = "setup" && EventLog[Date] = PreviousDate ) ) RETURN IF ( EventLog[Semi.Mat.No.] = PreviousMaterial, BLANK (), 1 ) ) RETURN COUNTX ( FILTER ( mytable, [Asim] = 1 ), 1 )
ultimatly count will be the desire result.
| Date | Machine | Event | Duration | Order | Semi.Mat.No. | Count |
| 1/16/2018 1:55 | E120N1 | setup | 35 | 3543589 | IIC37TCX6Y | 1 |
| 1/16/2018 4:24 | E120N1 | setup | 26 | 3543589 | IIC37TCX6R | 1 |
| 1/16/2018 7:10 | E120N1 | setup | 8 | 3543589 | IIC37TCX6U | 1 |
| 1/16/2018 8:52 | E120N1 | setup | 100 | 3543809 | IIC61YCX6K | 1 |
| 1/16/2018 14:09 | E120N1 | setup | 15 | 3543809 | IIC61YCX6K | 0 |
| 1/16/2018 18:17 | E120N1 | setup | 22 | 3543809 | IIC61YCX6K | 0 |
| 1/16/2018 20:33 | E120N1 | setup | 20 | 3543504 | IIC37T4X6K | 1 |
Try this calculated column
Column =
VAR PreviousDate =
CALCULATE (
MAX ( EventLog[Date] ),
FILTER (
ALLEXCEPT ( EventLog, EventLog[Machine] ),
EventLog[Event] = "setUp"
&& EventLog[Date] < EARLIER ( EventLog[Date] )
)
)
VAR PreviousMaterial =
CALCULATE (
FIRSTNONBLANK ( EventLog[Semi.Mat.No.], 1 ),
FILTER (
ALLEXCEPT ( EventLog, EventLog[Machine] ),
EventLog[Event] = "setUp"
&& EventLog[Date] = PreviousDate
)
)
RETURN
IF ( EventLog[Semi.Mat.No.] = PreviousMaterial, 0, 1 )- Zubair_Muhammad8 years agoCommunity Champion
- Asim8 years agoHelper I
Good Morning!
Thank you very much dear, you made my life so easy,
This solution is perfect!
Best Regards
Asim
- Asim8 years agoHelper I
Dear, the calculated column which you suggested earlier is working perfect except consuming RAM, The solution using below mentioned measure you suggested is not returning the desire result.
could you please check!
Regards
Asim
Setup Count =
VAR PreviousDate =
CALCULATE (
MAX ( EventLog[Date] ),
FILTER (
ALLEXCEPT ( EventLog, EventLog[Machine] ),
EventLog[Event] = "setup"
&& EventLog[Date] < SELECTEDVALUE ( EventLog[Date] )
)
)
VAR PreviousMaterial =
CALCULATE (
FIRSTNONBLANK ( EventLog[Semi.Mat.No.], 1 ),
FILTER (
ALLEXCEPT ( EventLog, EventLog[Machine] ),
EventLog[Event] = "setup"
&& EventLog[Date] = PreviousDate
)
)
RETURN
IF ( SELECTEDVALUE ( EventLog[Semi.Mat.No.] ) = PreviousMaterial, BLANK (), 1 )- Zubair_Muhammad8 years agoCommunity Champion
Give this a shot
Setup Count = VAR PreviousDate = CALCULATE ( MAX ( EventLog[Date] ), FILTER ( ALLEXCEPT ( EventLog, EventLog[Machine] ), EventLog[Event] = "setup" && EventLog[Date] < SELECTEDVALUE ( EventLog[Date] ) ) ) VAR PreviousMaterial = CALCULATE ( FIRSTNONBLANK ( EventLog[Semi.Mat.No.], 1 ), FILTER ( ALLEXCEPT ( EventLog, EventLog[Machine] ), EventLog[Event] = "setup" && EventLog[Date] = PreviousDate ) ) RETURN SUMX ( SUMMARIZE ( EventLog, EventLog[Machine], EventLog[Semi.Mat.No.] ), IF ( EventLog[Semi.Mat.No.] = PreviousMaterial, BLANK (), 1 ) )