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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Ikeumlaut
Advocate I
Advocate I

Calculated measure in custom time series

I have data from thousands of devices in a "raw" format where I have time of message sent from individual devices: message value (0 or 1), and device id. I want to create a 10min interval bar chart time series graph of this data, see example picture. I want to sum the values of all devices by their max value sent during the 10min interval, meaning if for example at 10:31 the devices value is 0 and at 10:34 values is 1 the value used to sum would be 1.

 

My thinking goes like this

  1. Create a new table with all time stamps for the time series. I guess doing a summarized table of all dates and crossjoining it with a table with the 10min values would be the best way to go?
  2. Create a releation ship between this new table and the raw data table
  3. Create a Measure that does the calculation. Need help on this, how to do it
  4. Create a bar graph where x-axis is the 10min time series and y-axis is the calculated measure

Am I on the right track and what would be the best way to solve this problem?

 

Here is the raw data format:

TimeDeviceIDValue
28.3.2018 14:1410A1
28.3.2018 13:5810A1
28.3.2018 13:3810A0
28.3.2018 13:0610A1
28.3.2018 12:4910A1
28.3.2018 12:3310A1
28.3.2018 12:1710A0
28.3.2018 11:4910A1
28.3.2018 11:3210A1
28.3.2018 10:4810A1
28.3.2018 10:1610A0
28.3.2018 14:1320B1
28.3.2018 13:5720B1
28.3.2018 13:4120B1
28.3.2018 13:2520B1
28.3.2018 13:2120B0
28.3.2018 12:4920B1
28.3.2018 12:3320B1
28.3.2018 12:1720B1
28.3.2018 12:0120B1
28.3.2018 10:1820B

0

 

Here is how the data should look like to create the bar graph:

TimeTotal Value
28.3.2018 14:102
28.3.2018 14:002
28.3.2018 13:502
28.3.2018 13:401
28.3.2018 13:301
28.3.2018 13:202
28.3.2018 13:102
28.3.2018 13:002
28.3.2018 12:502
28.3.2018 12:402
28.3.2018 12:302
28.3.2018 12:201
28.3.2018 12:101
28.3.2018 12:002
28.3.2018 11:501
28.3.2018 11:401
28.3.2018 11:301
28.3.2018 11:201
28.3.2018 11:101
28.3.2018 11:001
28.3.2018 10:501
28.3.2018 10:401
28.3.2018 10:300
28.3.2018 10:200
28.3.2018 10:100

 

and here the graph I'm aiming for:

Capture.PNG

 

Thanks!

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @Ikeumlaut,

 

You can refer to below steps to achieve your requirement.

 

Steps:

1. Add calculated column category to original table.

Category =
LEFT ( [Time], LEN ( Table1[Time] ) - 1 )
    & "0"

2. Create new table to generate expand date range.

Table = 
VAR _date =
    DISTINCT (
        SELECTCOLUMNS (
            Table1,
            "Date", DATEVALUE ( SUBSTITUTE ( LEFT ( [Time], 10 ), ".", "/" ) )
        )
    )
RETURN
    SELECTCOLUMNS (
        CROSSJOIN (
            _date,
            SELECTCOLUMNS (
                CROSSJOIN (
                    GENERATESERIES ( 0, 23 ),
                    SELECTCOLUMNS ( GENERATESERIES ( 0, 5 ), "Minute", [Value] * 10 )
                ),
                "Time", TIME ( [Value], [Minute], 0 )
            )
        ),
        "DateTime", DATEVALUE ( [Date] ) + TIMEVALUE ( [Time] )
    )

3. Add calculated column to format datetime to specific category, setting sort by column 'datetime'.

Category = FORMAT([DateTime],"dd.m.yyyy hh:mm" )

1.PNG

 

4. Add relationship between two category columns.(setting 'both' for 'cross filter direction' option)

5. Add a measure to original table to calculate total value of same category.

Amount = SUM(Table1[Value])+0

6. Create line chart.

2.PNG

 

I also attached sample file.

 

Regards,

XXiaoxinShneg

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hey @v-shex-msft,

 

thanks it seems to bee working! However, I realized my problem is a bit more complex 😄

 

I need to calculate a "cumulative sum" as each device does not sent every 10min interval a message. So if a device has not sent a message during the 10min interval I need to look what was the previous message on use that value, so "print" last value in time forward until a new values has been received from deivce. I found this topic/solution, but it is on a daily level.

 

Here is the matrix I have now:

Device3.4.2018 12:103.4.2018 12:203.4.2018 12:303.4.2018 12:403.4.2018 12:503.4.2018 13:003.4.2018 13:103.4.2018 13:203.4.2018 13:303.4.2018 13:40
A1 11 1 11 
B1   011 1 
C1 1  0    
SUM Gives:3021021120

 

Here is how the data should look like:

Device3.4.2018 12:103.4.2018 12:203.4.2018 12:303.4.2018 12:403.4.2018 12:503.4.2018 13:003.4.2018 13:103.4.2018 13:203.4.2018 13:303.4.2018 13:40
A1111111111
B1111011111
C1111100000
Should give :3333222222

 

Thanks!

Hi @Ikeumlaut,

 

Actually, I also onside how to display nonexistent records. For original table, some of records not real stored in it.

 

On my opinion, I'd like to suggest you use original table and calendar table to create new expand table with all detail records.(setting value of new records to zero)


After above steps, you can try to write a measure to replace displayed values.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.