DATE() function in PowerBI not working - does not recognize year value - date

Does anyone know why I am encountering this error with the most basic operation in PowerBI? After a few tries myself only ending in errors I copied the syntax straight off MS site and still......error.
I created a new table and used the following:
Table = calendar(date(2000,1,1),date(2030,12,31))
Error received:
Too few arguments were passed to the DATE function. The minimum
argument count for the function is 3.
When adding the arguments its as if the DATE function does not recognize the year value at all.
Anyone else encountering this?
Also, I noticed a lot of search results advising to use the "Modelling" tab which I don't have in my desktop version. I am currently still on a free trial.
Does a free trial mean I can not use the most basic DATE() function - I truly hope this is not the case.

Related

Google spreadsheet month name (MMMM) without declension

I want to display formatted month name in the basic form (nominative) as a label. In Czech language (and several next Slavic languages) we use declension. So if I use =TEXT(NOW();"MMMM") the cell shows month name in genetive instead of nominative (i.e. srpna instead of srpen).
Q: How to format the date in the nominative? The acceptable solution will offer some native way how to solve it but not:
manipulating with strings (month names are too complex)
having some another list with month names
calling own formula (Google script)
Maybe there is no native way how to solve this and it will be implemented in the future, so Google Script seems to be the easiest hotfix for now. And because I'm expecting many answers with the script, I'm putting the one here but this question is not about the javascript/google-script.
function monthName(date) {
var months = ["Leden","Únor","Březen","Duben","Květen", "Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec"];
return months[date.getMonth()];
}

In Jaspersoft Studio, how do I use the DATEFORMAT() function?

Here's a screenshot:
Here's a screenshot http://www.coletrumbo.com/wp-content/uploads/2015/05/dateformat-1024x575.png
I'm trying to turn the current date into July 1st of the current year using DATEFORMAT(). I learned how to do that in MySQL from this question, and I hoped it would work similarly in Jaspersoft Studio- turns out date_format( curdate(), '%Y-07-01' ) doesn't translate into
DATEFORMAT( TODAY(), '%Y-07-01' ) or DATEFORMAT( TODAY(), YY/07/01 ). Neither worked.
I could keep trying to get creative and hopefully find something that works, but I'd rather actually understand how to use DATEFORMAT().
I checked the Jaspersoft Studio User Guide, but it's not there. From the prompts on the screen, it makes a lot of sense, but I just can't figure out the "format pattern" that I'm allowed to apply, or even how to correctly write any format pattern at all. Also, this conveniently named question, DateFormat Pattern, didn't actually help at all. And community.jaspersoft.com/answers is kind of a joke in my opinion. When I checked it a couple days ago, it was filled with spam linking to live hockey games.
Thanks in advance. I'm sure this is a beginner level question, so I feel dumb asking it, and I feel like I'm wasting other people's space and time with it because I should already know. So I really appreciate your willingness to care.
I am using the following to get the todays date in a danish format
"Dato: "+new java.text.SimpleDateFormat("dd MMMM yyyy",new
Locale("da", "DK")).format(new Date())
you can find the source code for the DateTime functions directly in JR repository: https://sourceforge.net/p/jasperreports/code/ci/master/tree/jasperreports/demo/samples/functions/src/net/sf/jasperreports/functions/standard/DateTimeFunctions.java
As you can see the code is fairly simple and relies on the Joda Time library.
Therefore the second parameter you are trying to enter is a String, while the first one is a Date object.
Indeed something that could work for you is an expression like this DATEFORMAT(TODAY(), "07-01-YYYY")
Regards,
Massimo.

DATEDIF statement in SharePoint not working properly

I am trying to calculate the amount of days between two dates but my formula doesn't seem to be working properly. It's as is the function is ignoring the years in the dates. My function is as follows:
=IF([Today's date]>[Expiration Date],-DATEDIF([Expiration Date],[Today's date],"d"),(DATEDIF([Today's date],[Expiration Date],"d")))
I receive this error if I use the above function(Owners removed):
But then I replace -DATEDIF([Expiration Date],[Today's date],"d") with -DATEDIF([Today's date],[Expiration Date]"d") i get this result:
This is telling me that both cases are being treated as IF([Today's date]>[Expiration Date] even though 3/24/2015 is clearly larger than 11/03/2014. Can somebody please tell me what I'm doing wrong? Thanks.
=[ExpirationDate] - [TodaysDate]

regarding calculating business days/holidays

does anyone know where I can download this zip file called "businessdays.zip" which was mentioned from this link ... http://www.tek-tips.com/viewthread.cfm?qid=136159 ... I mean is there a better way of calculating business days/holidays than what is previously written here ... http://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_21376129.html ... I've tried this but method from experts-exchange, registered the dll but still not working for me. Can anyone help?
You could create a custom function that returns an array of holidays. See my answer to Crystal Report exclude time entries based on holiday rules.
In this post there is a function that takes a start date, and end date and return the number of working days in between. Also takes holidays into account.

How to make Jasper Reports programmatically determine the Name of Columns within the report it self?

I am generating a report with that will have a 7 columns where the last 6 should have the the last 6 months listed. So as of the time of this writing it should be:
NAME -> September -> August -> July -> June -> May -> April
ss the column headers. I am trying to avoid having to pass them in as parameters, and am trying to get Jasper Reports to figure it out at runtime. I can get the first month pretty easily using a Text Field Expression. It looks like:
new java.text.SimpleDateFormat("MMMMM").format(new Date())
The issue comes in with the other months. I initially tried
new java.text.SimpleDateFormat("MMMMM").format(java.util.Calendar.getInstance().add(Calendar.MONTH, new Integer("-1)).getTime())
This does not work since Calendar.add does not return a Calendar instance. I then tried using a variable and then a combination of variables which also did not work.
How to make Jasper Reports programmatically determine the Name of Columns within the report it self?
I think the best approach to solving this problem is to use Commons Lang. That package provides utilities to make calculations like this very easy. By adding one extra jar you can then use expressions like this:
DateUtils.addMonths(new Date(),-1)
I find that easier to maintain than first creating a helper Calendar class and then using the ternary operator but ignoring its results.
$P{cal}.add(Calendar.MONTH, -1)
? null : $P{cal}.getTime()
If you ever need to generalize the solution then it's a lot easier to get a Date back from a SQL query than to get a Calendar. So you can quickly change to "DateUtils.addMonths($F{MyDate},-1)". Initializing a Calendar to match a date returned by a query isn't nearly as simple. But of course there's a certain benefit to not having to add one more .jar file. So sometimes that ternary operator technique is the quickest way to get things done.
I wrote about using the Commons Lang approach a couple of years ago here: http://mdahlman.wordpress.com/2009/09/09/jasperreports-first-dates/
I also needed a certain format for the previous month. I ended up combining the other two answers:
new java.text.SimpleDateFormat("yyyyMM").format(
org.apache.commons.lang3.time.DateUtils.addMonths(
new java.util.Date(),
-6
)
)
This way I don't need to add another parameter. Adding the Commons Lang jar is a non issue for me since JasperServer 5.5 comes with version 3.0 out of the box.
I hope this helps someone who stumples upon this page, just like I did.
I found a working solution that is pretty ingenious (no I did not come up with it). I found it here. The gist of it is create a parameter called call, with a default value of:
Calendar.getInstance()
and un-check the option 'Use as a prompt'. Then in your text field expression you would do:
new java.text.SimpleDateFormat("MMMMM").format(
(
$P{cal}.add(Calendar.MONTH, -1)
? null : $P{cal}.getTime()
)
)
What happens is it will set the default value for the calendar instance, then execute the add method, which will resolve to false, so then it will then return the result from getTime() method which gets formatted how I want.