I have an SSRS report and I would like to be able to hide all the columns that come after the last column with data.
For example, columns are the months of the year, January through December.
For each month I have a value, some months have zero. I only want to display up to the last month that has a value, and hide all columns after that.
If the report looks like this:
jan feb march april may june july august september october november december
1 0 1 0 0 0 0 0 1 0 0 0
I only want to display January to September
Thanks
You can use an expression for hiding the column group when it meets the requirements
= Iif(SUM(Fields!value.Value)=0 AND RunningValue(Fields!value.Value, Sum,"Tablix1") = SUM(Fields!value.Value, "Dataset1"),True,False)
Change the field and dataset names to match your tablix
Related
I currently have a monthly list of generated revenue but it is incorrectly accounted for and I have to change the dates to the previous month. For example, December revenue actually corresponds to November, May to April, February to January... and so on historically over the years.
The table I have made from groupings by month and year is the following:
Month
2021
2022
1
7.582
7.242
2
2.456
2.992
3
34.513
4.566
4
57.433
9.991
5
35.788
8.689
6
52.466
7.600
7
35.657
26.246
8
44.673
54.345
9
92.376
57.885
10
3.444
86.685
11
34.788
67.246
12
0
57.378
Which approach should I use in this case? I am using Metabase.
This question already has answers here:
How to group by month and return zero if no value for certain month?
(3 answers)
Closed 3 years ago.
I have "MySQL Query" with a table of data items in 1 year. I want to display based on month grouping.
SELECT MONTHNAME(create_date) AS month, COUNT(*) AS cplan FROM nota_jual GROUP BY month
I want the data displayed to include items with a value of 0 every month.
month cplan
January 3
February 2
March 0
April 0
May 0
June 0
July 8
August 8
September 6
October 3
November 5
December 3
can some one help /answer this? (Thankyou)
Check this
SELECT date_format(tn.create_date,'%m') as Month, count(*) as cpplan
FROM nota_jual tn
GROUP BY Month
ORDER by Month;
I have created a ssrs report and this report display last 12 months data. I have 2 parameters startDate and Enddate.
The End date is always the current month and I want the start date to be the last 12 months. For example if my (End Date) current month is JAN 2018. I want my start date to be Feb 2017.
I have below expression but this give me Jan 2017 date for my start date.
=DateAdd("M", -12,Today())
Try this expression for the start date parameter default value.
=DateAdd(DateInterval.Year, -1, DateAdd(DateInterval.Month, 1, Parameters!EndDate.Value))
Here's what the parameter values would equal:
I'm trying to use the Previous() function in a report indicator to display an up or down arrow depending on if there has been an increase or decrease from last year. This works fine when the data is displayed in ascending order, but when displayed in ascending order the Previous() function no longer works, it just treats the top row as the oldest. I've created a custom code.PercentDifference (Num, PrevNum) to get the differences. To illustrate, this is a table in SSRS, Year Change is a calculated column using an expression:
Financial Year Value (Year Change)
Apr 2007 - Mar 2008 30,000 0
Apr 2008 - Mar 2009 37,000 7,000
Apr 2009 - Mar 2010 42,000 5,000
Apr 2010 - Mar 2011 38,000 (4,000)
This works OK, since row 2 'sees' Current-Previous as 37000-30000. However when displaying by date descending like so I get this:
Financial Year Value (Year Change)
Apr 2010 - Mar 2011 38,000 0
Apr 2009 - Mar 2010 42,000 4,000
Apr 2008 - Mar 2009 37,000 (5,000)
Apr 2007 - Mar 2008 30,000 (7,000)
Because row 2 sees Current-Previous as 42000-38000, and row 1 has no concept of row 2?!
It needs to look like this:
Financial Year Value (Year Change)
Apr 2010 - Mar 2011 38,000 (4,000)
Apr 2009 - Mar 2010 42,000 (5,000)
Apr 2008 - Mar 2009 37,000 7,000
Apr 2007 - Mar 2008 30,000 0
I don't think I can do it in the original dataset query, since this just pulls out lots of values against individual dates, then does some computed columns to e.g. work out financial year, month etc. The tables above are reporting sums grouped by year.
Any ideas how I can produce this?
Many thanks,
I used previous in a "reverse" way:
In my example I used the previous function for period and valuesale data, and normal value for previous data.
Also I hide the first row (no meaning to show), and show the last period at the footer
To control visibility of the first row use: =Previous(Fields!fiscalmonth.Value) is Nothing
When you are sorting by date in the descending order, it seems instead of the previous value you need the next value.
SSRS doesn't provide any next function unlike Crystal.
Here what you can try is creating a queried parameter which takes the value of field "Value" and write an expression like :
Parameters!Value.Value((RowNumber(nothing)) - Parameters!Value.Value((RowNumber(nothing)+1)
The main idea is you can get the value as an indexed array for example Parameters!Value.Value(i) will give you the ith record of the "Value" field.
And you'd need function RowNumber to get the running count of rows.
Does anyone know a way to convert a month, year, and day into the day's name for any year? Example:
function convert(day, year, month)
...
return "Monday"
end
Thanks in advance!
You can use the following method:
This method uses codes for different
months and years to speed up the
calculation of the day of the week.
You might even be able to memorize the
codes. We'll use December 16, 2482 as
an example.
Take the last 2 digits of the year. In
our example, this is 82.
Divide by 4, and drop any remainder.
82 / 4 = 20, remainder 2, so we think
"20."
Add the day of the month. In our
example, 20 + 16 = 36.
Add the month's key value, from the
following table. Jan Feb Mar Apr May
June July Aug Sept Oct Nov Dec 1 4 4
0 2 5 0 3 6 1 4 6
The month for our example is December,
with a key value of 6. 36 + 6 = 42.
If your date is in January or February
of a leap year, subtract 1. We're
using December, so we don't have to
worry about this step.
Add the century code from the
following table. (These codes are for
the Gregorian calendar. The rule's
slightly simpler for Julian dates.)
1700s 1800s 1900s 2000s 4 2 0 6
Our example year is 2482, and the
2400s aren't in the table. Luckily,
the Gregorian calendar repeats every
four hundred years. All we have to do
is add or subtract 400 until we have a
date that is in the table. 2482 - 400
= 2082, so we look at the table for the 2000s, and get the code 6. Now we
add this to our running total: 42 + 6
= 48.
Add the last two digits of the year.
48 + 82 = 130.
Divide by 7 and take the remainder.
This time, 1 means Sunday, 2 means
Monday, and so on. A remainder of 0
means Saturday.
How to calculate the day of the week
A quickl google for "day of week from date algorithm" showed up this Wikipedia article
But depending on the dates you need to work with, beware the strange history of Gregorian calendar adoption