Hi,
I am new to Power Bi and DAX.
I need to show a trend line for the last 12 hours production for each record in a table . I have used DAX measure to draw a sparkline graph and changed the category of the measure to Image URL to display it as an image in the table . But for some reason the graph is compressed and I am not able to view the data points properly.
It is accumulating all the data on the right hand side of the graph if the last 12 hours include double digit. For example, if it is 10th hour of the day currently, the last 12 hours will include23rd hour from yesterday (last night) and 0-10 for today’s date.(i.e. from yesterday 10pm to 10AM today= last 12 hours).
Below is the screenshot of the issue:
DAX code for the sparkline graph:
ProductionTrend =
VAR LineColor = “#1E7ED1”
VAR XMinDate = MIN(‘Last12Hours’[HourCalc])
VAR XMaxDate = MAX(‘Last12Hours’[HourCalc])
VAR YMinValue = MINX(VALUES(‘Last12Hours’[HourCalc]),CALCULATE(SUM(Transactions[Unit Qty]))+0)
VAR YMaxValue = MAXX(VALUES(‘Last12Hours’[HourCalc]),CALCULATE(SUM(Transactions[Unit Qty]))+0)
VAR SparklineTable = ADDCOLUMNS(
SUMMARIZE(‘Last12Hours’, ‘Last12Hours’[HourCalc]),
“X”,INT(100 * DIVIDE(‘Last12Hours’[HourCalc]- XMinDate, XMaxDate - XMinDate)),
“Y”,INT(100 * DIVIDE(CALCULATE(SUM(Transactions[Unit Qty])+0) - YMinValue,YMaxValue - YMinValue)0.90 + (1000.05)))
VAR Lines = CONCATENATEX(SparklineTable,[X] & “,” & 100-[Y]," ", [HourCalc])
VAR SVGImageURL = IF(HASONEVALUE(‘WorkOrder’[Work Center]),
“data:image/svg+xml;utf8,” &
“” &
“”,
BLANK())
RETURN SVGImageURL
The correct graph should look like the big graph on the right hand side when selecting one sparkline as shown below:
Please find attached the pbix file to review the issue.
Production EfficiencyFINAL.pbix (3.0 MB)
Thank you very much in advance!