Forum Discussion

frankiekho's avatar
frankiekho
Helper I
2 years ago
Solved

How to count the status changes within a table

Hi, i am quite new to power bi, and have a problem with this dax i got a little task to count how many machines are being newly scrapped and newly delivered.   from the dataset i attach below, whe...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, frankiekho 

    You can try the following calculation list DAX expression. According to your reply with the previous Super User, and the Sample Data you provided:

    DAX formula:

     

    New column = 
    
    var _Date = 'Sheet1'[Start of the Month]
    
    var _status = CALCULATE(SELECTEDVALUE('Sheet1'[Status]),FILTER(ALL(Sheet1),'Sheet1'[Serial(OEM)]=EARLIER(Sheet1[Serial(OEM)])&&'Sheet1'[Start of the Month]<EARLIER(Sheet1[Start of the Month])))
    return
    
    if( 'Sheet1'[Status]<> _status ,
    
    Switch(true(),
    
    [Status]= "scrapped"&&_status="working", "Newly scrapped",
    
    [Status]= "working"&&_status="not delivered", "Newly Delivered"
    
    ), BLANK()
    
    )

     

    The calculation results are as follows:

     

     

    If the above DAX expression can help you, it is really good. I provided the pbix file I used this time.

     

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.