Forum Discussion

Brighton10's avatar
Brighton10
Icon for Helper II rankHelper II
5 years ago
Solved

Calculate the latest machine Status

Hello, 

I earlier asked about this related topic but felt i should attached the pbix file for clarity as i noticed something different. I want to write a measure to retrieve the latest machine status for the previous day. In the data view, if you filter Country = Ghana, Region = Accra, SiteName = "Atomic_Hills_T", environmentalStatus = "Gen_Cont_Inside_Temp". Then lastly order the dateTime in desc order before filter for day 7 (Am doing an analysis for day 7). I want to get the latest machineStatus which is 271 in this case and display it in my visual table. I want the logic to work for any country you filter on. Thanks for the help in advance!

https://drive.google.com/file/d/1jDxYPo_0nHmf4cENvHtqfbwuhNHP60_P/view?usp=sharing 

https://drive.google.com/drive/folders/1v53x-yJCVEY3uCNX95p5o3W1vPBNjjLz?usp=sharing

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Brighton10 ,

    You can try this measure 

    Measure =
    var _maxdate =CALCULATE(MAX('Table'[Activity Date]),FILTER('Table','Table'[Activity Date]<=MAX('Table'[Activity Date])&&'Table'[Account]=MAX('Table'[Account])&&'Table'[Activity ID]="Request"))
    var _1=CALCULATE(MAX('Table'[User ID ]),FILTER('Table','Table'[Activity Date]=_maxdate&&'Table'[Activity ID]="Request"))
    return
    IF(MAX('Table'[Account])=4,BLANK(),_1)

     

    Best Regards,

    Liu Yang

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

  • I have created this measure just to calculate Ghana but it returns the max of the machine status whilst i want the latest. 

    GeneratorContInsideTemp =
    VAR maxDate = CALCULATE(MAX(Analog[dateTime]))
    VAR machineStatus_ = CALCULATE(MAX(Analog[machineStatus]),Analog[environmentalStatus]="Gen_Cont_Inside_Temp",Analog[country]="Ghana",Analog[region]="Accra",Analog[siteName]="Atomic_Hills_T",Analog[machineStatus])*0.1
    return
    machineStatus_
     
    Can anayone assist?