Forum Discussion

NightStalker's avatar
NightStalker
Frequent Visitor
5 years ago
Solved

Displaying Max value of every 8 hours

I'm using custom Streaming Data. I use an ESP32 to push the real-time weight value of a sensor to Power BI API. However, I need a table displaying the weight max value of every 8 hours. My date colum...
  • NightStalker's avatar
    5 years ago

    I managed to do all of it. for the Peak, I used this Measure 

    ShiftPeak = CALCULATE(MAX(RealTimeData[Weight]), TOPN(1, RealTimeData, RealTimeData[DateShift], ASC, RealTimeData[Shift], ASC))  . However, I did a bit of manipulation from the ESP, so I push a DateShift (which is basically just a number value) and three shifts that already got determined by the ESP. Everything will be displayed fine as long as you don't choose Date (The Value that has DateTime. Note this is for API streaming dataset). The other problem that I was struggling with is to calculate the sum of the shift peaks, which miraculously worked with this measure 
    Shiftsum = SUMX(SUMMARIZE(RealTimeData, RealTimeData[DateShift], RealTimeData[Shift], "Peaks", MAX(RealTimeData[Weight])),[ShiftPeak])  .
    If you want to associate every ShiftPeak to which time it's occurred, I used another measure which is 
    PeakDate = CALCULATE(MAX(RealTimeData[Date]), TOPN(1, RealTimeData, RealTimeData[DateShift], ASC, RealTimeData[Shift], ASC, RealTimeData[Weight])) & " "  . (if you remove " ") the time won't be displayed for some reason, but the date will. 
    I'm sorry for the late reply cause I managed to do it way back. I'm just on a tight schedule to make a report about this project that I was working on. I hope this is very much helpful.