How to write MDX formula for a filter - ssrs-2008

I am working on a report in BI that includes 2 datasets. The screenshot below is of DataSet2 where I am trying to write a MDX filter expression for the query. What is the formula so that the query only shows rows from the past 2 months from today. I tried a few different formulas…[GamingDay].[Date] > CDate(DateAdd(‘m’,-2,Now())) and it returns an error. What is the correct formula to do this?
enter image description here

You need to use double quotes to resolve the issue. Take a look at the sample below
with member measures.t
as
CDate(
DateAdd("m",-2,Now())
)
select
{[Measures].[Internet Sales Amount],measures.t }
on columns,
[Product].[Category].[Category]
on rows
from
[Adventure Works]
Result

Related

How can I get totals for specific columns in table in a tableau

I have around 7 columns. I am using Totals from Analysis in the Dashboard for the table.
When I tried Totals, I am getting totals for each column. But I want 2, 3,5 column totals only.
Please help me.
By default, the totals apply for all columns, but you can fix that using a little trick:

How to get SUM and AVG from a column in PostgreSQL

Maybe I'm overlooking something, but none of the answers I found solve my problem. I'm trying to get the sum and average from a column, but everything I see is getting sum and average from a row.
Here is the query I'm using:
SELECT product_name,unit_cost,units,total,SUM(total),AVG(total)
FROM products
GROUP BY product_name,unit_cost,total
And this is what I get:
It returns the exact same amounts. What I need is to add all values in the unit_cost column and return the SUM and AVG of all its values. What am I missing? What did I not understand? Thank you for taking the time to answer!
AVG and SUM as window functions and no grouping will do the job.
select product_name,unit_cost,units,total,
SUM(total) over all_rows as sum_of_all_rows,
AVG(total) over all_rows as avg_of_all_rows
from products
window all_rows as ();
The groups in your query contain just one row if total is a distinct value. This seems to be the case with your example. You can check this with a count aggregate (value = 1).
Removing total and probably unit_cost) from your select and group by clause should help.

Cognos Crosstab Report Calculated Column Totalling Incorrectly

I have a report in Cognos 10.1.1 that is pulling Profit, Pounds, and Profit/Lbs. Each query has a field 'Measure Unit' that is labeled as 'Spread $', 'Spread Lbs' or 'Spread $/Lb'. It joins these three queries via a union and then loads them into a Crosstab list. The individual queries work correctly, and when dumped into a List Report are fine, but for some reason when in the crosstab report, the calculated profit/lbs column is always wrong. How can I get the calculated column to total correctly in the crosstab?
Three queries pull seperate Measure Units and measures for Profit, Lbs and Profit/Lbs.
The calculation for Profit.
The Calcuation for Profit/Lbs
Properties for the measure fields.
What the report looks like. Middle column should equal Spread $ / Spread Lbs, but does not when in crosstab.
Try to customize Solve Order for your calculations.
Default behavior is Total(Value1/Value2). You need to archive Total(Value1)/Total(Value2)
(Don't change your formulas, just set Solve Order for calculations)

How to set Fixed Rows of Tablix in SSRS

How to do the tablix fix rows? I need to fix the report to maximum 5 rows, if record more than 5 rows will not show . If records is only 3 record, first,second & third rows will place the data and 4 & 5 rows will leave it blank.
Ideally you should achieve it in SQL query or stored proc.
However if you want to achieve it in RDL then you have to use RowNumber function in expression.Create a Row group and then restrict data set.Use expression =CEILING(RowNumber(Nothing)/5)
Please have a look at below link for your reference.
http://www.sqlchick.com/entries/2010/9/11/displaying-fixed-number-of-rows-per-ssrs-report-page.html

Aggregate not populating chart correctly in SSRS

Below, I've attached a sample of my data as well as a sample of the chart output. I want to aggregate the data and include one row with this number; however, SSRS is just showing multiple of the same value.
In the example below, you'll notice there are 8 rows in Unit 1 and 8 rows in Unit 2, a
total of 13. How can I get Unit 1 to have one row which shows 8 and one row in Unit 2 to show 5? Currently, the expression is =COUNT(Fields!SubID.Value, "DataSet1").
I've also tried adding in a column full of the number 1 which I could use to Sum on, but that produced the same results.
Originally I was doing this all in SQL; that is, producing the exact output I want in SQL and then charting in SSRS. However, this is no longer a viable solution as the end user would like to be able to drill down into the details of the report. I do imagine, if there is no easy way to do this (which I feel like there has to be), that I could write two queries, having one show the report and the other show the details.
Thanks.
The second parameter of your count expression is the problem.
Don't use this:
=COUNT(Fields!SubID.Value, "DataSet1")
Try something like this instead:
=COUNT(Fields!SubID.Value, "UnitGroupName")
The group name should match what is shown in BIDS as the name you've given the grouping, such as under Row Groups.