Conditional LabelsFormat on Report Builder Chart - reportbuilder

I am trying to design a SSRS report where the end user can choose whether they want to view certain charts grouped by year or by month. The user chooses a value for the parameter #dategroup to determine this.
If #dategroup is "YEAR" the SQL groups and pulls row counts for the last 6 years. If #dategroup is "MONTH" it groups and pulls the last 6 months. The SQL is working fine, but I am struggling with getting the horizontal axis labels to format correctly on my report builder charts.
My query passes a "cte_date" column to the horizontal axis which is a date field. When the report is grouping by month I use the LabelsFormat properties grab the month part of the date. For example, if the query passes the value 2019-01-01 to the chart the LabelsFormat will convert that to "Jan". In this case the property LabelsFormat value is "MMM". When #dateformat is "YEAR", the horizontal axis in this case would be "2019", LabelsFormat "yyyy".
I have tried customizing the LabelsFormat property to
Iif(Parameters!dategroup.Value=YEAR,yyyy,MMM)
But this is not returning the desired results (month part if grouped by month, year part if grouped by year). Is there a way to format axis labels (which are dates) based on a parameter value?

The code in the question was close, it just needed some formatting changes. Add double quotes to the parameter value and formats. Enter the below code into the LabelsFormat property of the axis you want changed.
=IIf(Parameters!dategroup.Value="YEAR","yyyy","MMM")
If the #dategroup parameter is set to "YEAR", it will format the date to show just year. Otherwise, it will format date to the three letter month code.

Related

PowerBI, DAX. Is there a way to set an upper limit to a slicer?

I'm trying to create some measures using DAX on an underlying data model which I would then use for creating some visuals (line chart, bar chart etc.). Each table in the data model has a data field (date&time) that contains repeated dates and times (more occurencies with the same date&time). To use the metrics in the visuals I need the measures to be grouped for date (only date, not for time).
To achieve the task I've created a calendar table (using CALENDAR in DAX) to set-up a set of dates (only dates) to which refer at for every table in the data model and created relations (dates that points to calendar date) for every table. I set the upper limit of the calendar table to be a year ahead of the max date in the dataset, because some measures need to be evaluated in the future.
In the visual pages, I put a slicer that points to the calendar table dates, but the date interval is too wide. I need the slicer to have a more narrow interval, let's say, only "for the present and the past" but I prefer not to add another calculated table.
In your opinion, is there a way to limit the slicer without changing its reference to the calendar table?
Thanks!
For the calendar you may just use CALENDARAUTO(). It will expand automatically as the data model expands.
For the slicer, just select it, open the filter pane and define a filter with the upper limit you want.
You can use combination of 3 different slicer for your purpose. This is just another option that you can have a look on. There will be 3 slicer for Year, Month & Date. So Date slicer is you final slicer, with 2 other slicer on top of it to generate necessary Dates in the slicer. This way, you are not making any static restriction to generate the Date list but giving the user full control on the Date range. Here below is a sample how the slicers can be look in practical.
User can select any year or multiple year, any month or multiple month. Finally the date slicer will hold Date values accordingly.

DAX and FORMAT function

i have a field for date with date, month and year.In my visualization, I need date to be displayed in (MON-Year) format.
I switched to data view, created calculated column with
Mon-Year = FORMAT('table'[Date],"YYYY-MM")
Now it's getting displayed as (YEAR and Month number) but I want to change it as month name.
After changes in data view, when I close apply, the column is present but there is no data type visible.
Should I create different calculated fields for year and month separately and then concatenate it?
any help would be appreciated.
If you want month first, then maybe you should specify it that way.
Mon-Year = FORMAT('table'[Date],"MMM-YYYY")
This may be useful for you:
https://learn.microsoft.com/en-us/dax/custom-date-and-time-formats-for-the-format-function

Tableau Using Parameters for a Date Selector

I've been looking into making a date selector so instead of filtering by Month, Week by adding filters then displaying the quick filters to correspond. I want to be able to dynamically change the date so I can choose between Quarter, Month and Week in a single drop down.
I have made the selector part no problem it shows but when I come to my calculated field, it's not behaving how I would like.
Here is my calculated field:
CASE [Parameters].[Date Select]
WHEN 'Quarter' THEN QUARTER([Date])
WHEN 'Month' THEN MONTH([Date])
WHEN 'Week' THEN WEEK([Date])
END
This gives 2 errors...
Unknown Function QUARTER called
Unknown Function WEEK called
I am puzzled because the month one is fine.
Normally in tableau to get the month/quarter/week, I click on the Date dimension and select Month or week and it filters and displays like so: MONTH(Date).
Can anyone tell me where I'm going wrong and how I can pull the week and quarter from date in the calculated field so my selector will work.
Thanks.
There are no QUARTER and WEEK functions in Tableau, as you can see in the image below.
What you should be using to get these values are:
DATEPART('quarter',[Date])
DATEPART('week',[Date])
For filtering the date using your parameter as filter, I'll assume that you want to filter the current quarter, month or week. In this case you'll need to setup your paramaters like this:
Then you'll create a Calculated Field with the following formula:
DATEPART([Date Selector],[Date]) = DATEPART([Date Selector],TODAY())
This should give you a True/False dimension which you will use as filter for the value True. After that you should have a working parameter filtering your data accordingly to the value set.

Jasperreports time series chart timePeriod Expression

I have dataset with 00:00:00,00:00:15...
how to set it to be the timePeriod Expression to show one day's time from 00:00:00 to 23:59:59
i put (Date)new SimpleDateFormat("HH:mm").parse($F{time}) into the timePeriod Expression
but the chart just show one time point
If you don't have gaps you can use Line chart like DeGriz's link to Tarnschaf's answer.
If you may have gaps or would like to summarise the data ensure you use <timeSeriesDatasettimePeriod="Second"> or perhaps timePeriod="Minute" otherwise it tends to default to something large like a year, hence one data point.
THE JASPERREPORTS ULTIMATE GUIDE: Time Period Expression
This expression returns a java.util.Date value from which the engine will extract the
corresponding time period depending on the value set for the timePeriod attribute
mentioned earlier in the Time Series dataset. For instance, if the chart is about yearly
data, the engine will extract only the year from the date value, or if you are gathering
monthly data, the engine will use only the month value from the date object returned by
this expression.
I think you may also be asking to set the Min and Max for the axis to exactly one day, for this I believe you can use <domainAxisMinValueExpression> and <domainAxisMaxValueExpression>

SAS EG date issue

i want to build a bar chart where the X-axis is month year ( example : NOV 2010)
in my dataset i got a column called MonthYear contains the month year value.
The problem is when i use the MonthYear column as the X-axis value , in the bar chart X-axis it come out numeric value (example : 14800 ...). I google out and found out that it is the date value in SAS.
i would like to know how can i display date as "NOV 2010" form on X-axis in bar chart.
i tried to change it into a character value column but it is sort alphabetically.
Add the format monyy7. on the MonthYear column of the source dataset.