I want to fill the chart with data I pull via PHP from an API. For some reason I have issues to format the date correctly so the chart currently shows no bars with my data.
A data set from the random data looks like this:
{"t":1494806400000,"o":"35.19","h":"36.79","l":"33.94","c":"36.15"}
One from me like this:
{"t":1591092000,"o":"33.3900","h":"34.2000","l":"32.4100","c":"34.1900"}
I see that there are three 0 missing in mine, but even when I add them it's not working.
I have also checked the dates at https://www.unixtimestamp.com/index.php to find a difference but the original dates is outputted as 01/05/49229 # 12:00am (UTC) which looks very odd to me.
Can anyone tell me in which format the date needs to be? d M Y h:i:s is what I currently do in php, but it neither works without the seconds.
5-months later:
I would recommend looking into the Luxon Library to get the values for t,
https://moment.github.io/luxon/docs/class/src/datetime.js~DateTime.html
Other wise I do believe its Year Month Day hours:minutes:seconds
Related
I am learning Power BI Desktop. I have a project already loaded for which I have created a
pie chart.
As you can see, the data is currently divided into two years: 2022 and 2021.
I also have data for previous years that I want to include in the chart. Unfortunately, none of these years has a high number. So I want to group them all into an "Other" category.
I've already tried using the RANKX function as described here (where I copied and pasted the formula from the comment and replaced the field name with my own) and here (where I went through the article step by step using my own field names). I used the exact format shown in both the comment and the article:
Rank = RANKX('Table','Table'[Percent],,DESC,Dense)
(Table is the table name I am using and Percent is the column I am trying to rank.)
When I added the new column to a table, though, PowerBI automatically gave me a sum calculation. This calculation gave me a 1 in each column. When I asked it not to give me a sum, it said it could not display the visual and took me back to the calculation screen.
EDIT: Thanks for your help Kevin! This is the table I tried to draw from. I am an idiot sometimes.
EDIT 2: Now I am trying to use a different field in the formula:
Rank = RANKX('FactClaimActivity','FactClaimActivity'[DirectIncurredLoss_ITD])
(This is the original field that I tried to base Percent on)
My table looks like this. (Yes, I know that 2016, 2017, 2019 and 2020 have negative values and 2014 and 2015 have $0 values. I just want to show what the data is.)
EDIT 3: This time I am also getting an error when I type in the formula, which says "A single value for column 'DirectIncurredLoss_ITD' in table 'FactClaimActivity' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."
I do not understand why it wants a single result for a formula that ranks the data points based on this field. That seems like it defeats the whole purpose of the formula.
Yet when I use the formula, I get the same result as last time! This column is in the Fixed decimal number format, and it does have many different values.
EDIT: I've found the answer
New Category = IF('FactClaimActivity'[Rank]<=2,'FactClaimActivity'[LossYear],"Other")
The formula will help you get the correct result.
In Google Sheets, how can you use the IF statement using the output of a cell's formatted value?
I've created a Google Sheet with a date value in B1. The cell is formatted using the date format. B1 is then copied across to the right so that it increments the days of the month.
In B2, based on the B1 date, I want to display the day value (ie Thu, Fri, Sat etc.). Similarly to the first step, I set the date format under Format > Number > More formats > More date and time formats, then from the select box, choose the day and I want to display the "Tue" date format.
Then in B8, I want to display an amount of 30 every Thursday, otherwise, show 0.
This is where it doesn't work. Does it seem like the rendered cell's value can't be used in an IF statement? My desired output is that every the value in row 2 is a 'Thu' display 30.
As a side note, I jumped on Google support and asked this same question. Even though they are technical support, I thought I'd give them a try anyway, after all, I am paying for GSuite.
This is the formula they came back to me with: =if(B2=B1, "30", "0").
Of course, this formula will work in B8, because B2 is equal to B1 in the actual cell value, it doesn't take into account the formatted cell value. This formula will fail the output we need as it will always display 30 instead of only then row 2 is 'Thu'.
So essentially, is there a function in Google Sheets for a rendered cell value? Or another solution around this?
Note: I do NOT want to use any scripting to get this to work.
try it like this:
=IF(TEXT(B2, "ddd")="Thu", 30, 0)
Please try and copy across to suit:
=30*(WEEKDAY(B1)=5)
No IF, but shorter.
In my report, my date dropdown slicer looks like this when the report first loads:
I want it to display without all the extra time and timezone nonsense like it does when I manually select one of the boxes after the report loads:
Does anyone know why this happens or how to fix it?
Edit: Here's a minimal .pbix example: Link to File
I'm on the August 2018 version now, and it seems to me that this issue has been fixed.
At least I'm not able to reproduce it.
With a dataset like below, a Line Chart and a regular Slicer, I get this:
Date,Value
2017-01-12,1
2017-01-13,4
2017-01-14,2
2017-01-15,4
2017-01-16,2
2017-01-17,2
2017-01-18,2
2017-01-19,5
2017-01-20,5
2017-01-21,5
2017-01-22,5
2017-01-23,6
2017-01-24,3
2017-01-25,6
2017-01-26,6
2017-01-27,5
2017-01-28,8
2017-01-29,4
2017-01-30,2
The slicing details (the All part in Date All) can be turned off by setting Filter Restatement under Slicer Header to Off. Maybe that would have solved the issue?
Please note that I've ignored the date hierarchies in both the Line Chart and the Slicer:
As a suggestion, you might want to try creating a new Column using the FORMAT function.
This is something I often do to provide a more human readable date for my slicer.
EG:
DisplayDate = Format([SomeDateField], "ddd d mmm yyyy" )
Once done - you will want to select the column - then SORT by your original date column. Otherwise you may get some odd results ;)
This is formula that i use
CALCULATE(SUM(Dates[IsWorkDay]),DATESBETWEEN(Dates[Date],
'table1'[date1],'table1'[Date2])))
This is the formula I use... between dates that look like below image.. I want to exclude weekends..... but the result that I get is not correct .... when the actual difference is only one day ... I get it as 4 days ... it differs a lot.. can some one please help
enter image description here
The Data type of all the dates in the formula needs to be in the same format.
For Example: keep it as just date(mm/dd/yy).
Your calculated column is right and it should work once you fix the data types.
I am working with a DB2 database for the first time.
I am trying to work with DB2 dates, but the data is stored as a string in the DB2 database.
I want to convert this date-string into an actual date, preferably dropping off time because I want all transactions between 1 Jan 2011 and 26 Jan 2011.
So essentially, I want this MS SQL statement in DB2 magic...
CONVERT(datetime,SETTLEMENTDATE.VALUE,103)
For background, I have got as far as
CAST(SETTLEMENTDATE.VALUE, DATE)
AND
DATE(SETTLEMENTDATE.VALUE)
But I need the expert knowledge of a DB2 whizzkid!
Thanks
Based on your own answer, I'm guessing that your column has data formatted like this:
'DD/MM/YYYY HH:MI:SS'
The actual separators between Day/Month/Year don't matter, nor does anything that comes after the year.
You don't say what version of DB2 you are using or what platform it's running on, so I'm going to assume that it's on Linux, UNIX or Windows.
Almost any recent version of DB2 for Linux/UNIX/Windows (8.2 or later, possibly even older versions), you can do this using the TRANSLATE function:
select
date(translate('GHIJ-DE-AB',column_with_date,'ABCDEFGHIJ'))
from
yourtable
With this solution it doesn't matter what comes after the date in your column.
In DB2 9.7, you can also use the TO_DATE function (similar to Oracle's TO_DATE):
date(to_date(column_with_date,'DD-MM-YYYY HH:MI:SS'))
This requires your data match the formatting string; it's easier to understand when looking at it, but not as flexible as the TRANSLATE option.
I know its old post but still I want to contribute
Above will not work if you have data format like this 'YYYMMDD'
For example:
Dt
20151104
So I tried following in order to get the desired result.
select cast(Left('20151104', 4)||'-'||substring('20151104',5,2)||'-'||substring('20151104', 7,2) as date) from SYSIBM.SYSDUMMY1;
Additionally,
If you want to run the query from MS SQL linked server to DB2(To display only 100 rows).
SELECT top 100 * from OPENQUERY([Linked_Server_Name],
'select cast(Left(''20151104'', 4)||''-''||substring(''20151104'',5,2)||''-''||substring(''20151104'', 7,2) as date) AS Dt
FROM SYSIBM.SYSDUMMY1')
Result after above query:
Dt
2015-11-04
Hope this helps for others.
In format function your can use timestamp_format function.
Example, if the format is YYYYMMDD you can do it :
select TIMESTAMP_FORMAT(yourcolumnchar, 'YYYYMMDD') as YouTimeStamp
from yourtable
you can then adapt then format with elements format foundable here
Okay, seems like a bit of a hack. I have got it to work using a substring, so that only the part of the string with the date (not the time) gets passed into the DATE function...
DATE(substr(SETTLEMENTDATE.VALUE,7,4)||'-'|| substr(SETTLEMENTDATE.VALUE,4,2)||'-'|| substr(SETTLEMENTDATE.VALUE,1,2))
I will still accept any answers that are better than this one!
You can use:
select VARCHAR_FORMAT(creationdate, 'MM/DD/YYYY') from table name