Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi,
I have a json object as follows.
{
"Hour" :1,
"Good" :11,
"Reject" :1,
"Rework" :0,
"Target" :50
}I need to visualze these data in cards and need to update a dashboard in real time.
I need to show the hour in one card,good number in another,reject in another etc.I've tried with streaming api and pushed data.When i push the data seconed time as follows,
{
"Hour" :1,
"Good" :15,
"Reject" :1,
"Rework" :2,
"Target" :50
}Card values are aggregated and shows a sum. What i need is to show the good,reject,rework values for particular hour.
Also i need to use a line chart and show data for 10 hours.
Is there a way to achive this?
Hi @chathu,
How did you create the Streaming dataset?
I have tested it with creating a streaming dataset(API) by pushing data using the streaming sample code below, and the data shown on the Card visual is not aggregated in my test.
//Copyright Microsoft 2016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace PBIRealTimeStreaming
{
// Sample app demonstrating how to use the Power BI REST APIs for streaming data
// Pushes current datetime and a random integer to the REST API every second
// Full documentation: https://powerbi.microsoft.com/documentation/powerbi-service-real-time-streaming/
// To run this sample:
// 1. Go to app.powerbi.com
// 2. Go to streaming data management page by via new dashboard > Add tile > Custom Streaming Data > manage data
// 3. Click "Add streaming dataset"
// 4. Select API, then Next, and give your streaming dataset a name
// 5. Add a field with name "ts", type DateTime
// 6. Add a field with name "value", type Number
// 7. Click "Create"
// 8. Copy the "push URL" and paste it as the value of "realTimePushURL" below
class Program
{
// Paste your own push URL below
// e.g. https://api.powerbi.com/beta/2b958e42-b81e-441d-af13-801621ce8401/datasets/a5a15fd1-8cb6-4527-b2e6-f22f2a274d4d/rows?key=apsBX1ef%2F8a7ToL2GuTyfCQKIYASbbDBbZeGATSyRYerZKpnu%2FbE2g2yDM0%2Bs4cDW9mqu5zKoGcQ27vJuh0Huw%3D%3D
private static string realTimePushURL = "";
static void Main(string[] args)
{
while (true) {
try
{
// Declare values that we're about to send
String currentTime = DateTime.UtcNow.ToString();
Random r = new Random();
int currentValue = r.Next(0, 100);
// Send POST request to the push URL
// Uses the WebRequest sample code as documented here: https://msdn.microsoft.com/en-us/library/debx8sh9(v=vs.110).aspx
WebRequest request = WebRequest.Create(realTimePushURL);
request.Method = "POST";
string postData = String.Format("[{{ \"ts\": \"{0}\", \"value\":{1} }}]", currentTime, currentValue);
Console.WriteLine(String.Format("Making POST request with data: {0}", postData));
// Prepare request for sending
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Console.WriteLine(String.Format("Service response: {0}", ((HttpWebResponse)response).StatusCode));
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
// Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
// Wait 1 second before sending
System.Threading.Thread.Sleep(1000);
}
}
}
}
In addition, you should be able to show the history value for a period of time on the line chart. ![]()
Regards
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.