I'm new to OLAP cubes. Can you directed in the right direction with small example.
Let's say I have table "transactions" with 3 columns: transaction_id (int), date (datetime), amount (decimal(16,2)).
I want to create a cube and then get data with MDX query for SSRS report.
I want report to show something like:
Ok. I know i can have fact table with amount and date dimention (date->month->year).
Can you explain what to do in order to get this result (including how to write MDX query). Thanks.
Can someone explain why I get amount of full 201504 and 201606 months even if I specified exact range with days?
SELECT
[Measures].[Amount] ON COLUMNS
,[Dim_Date].[Hierarchy].[Month].MEMBERS ON ROWS
FROM
[DM]
WHERE
(
{[Dim_Date].[Date Int].&[20150414] : [Dim_Date].[Date Int].&[20160615]}
)
Something like below, change the query accordingly :)
SELECT
{ [Date].[EnglishMonthName].[EnglishMonthName]} ON COLUMNS,
{ [Date].[DateHierarchy].[Year].&[2015],
[Date].[DateHierarchy].[Year].&[2016] } ON ROWS
FROM [YourCubeName]
WHERE ([Measures].[amount])
So you want someone to show you how to create a multi-dimensional cube from scratch and report on it in a single answer...? Start here and work through the lessons
Related
Normally in Tableau to calculate % I create a measure and use the below logic;
SUM ([MEASURE_1])/ SUM([MEASURE_2])
However i am trying to get the % when using a measure and an already aggregated measure and I'm getting the below error;
Argument to SUM (an aggregate function is already an aggregation, and cannot be further aggregated.
My percentage is to calculated the % difference between a policy count from table 1 which is a measure. and measure 2 which I had to create to get the count of policies from table 2 as follows; Count([Policy]). I'm using SQL Server database.
Any ideas how i can resolve this issue?
Thanks!
Measure 1 is a count from table 1, the data looks like the following;
Measure 2 is from table 2, I am creating a count in tableau of the policy number, the data looks like the below;
The 2 tables join on agent number
Table 1 structure;
[UNIQUEPOL_CNT]
,[UNIQUEAGT_CNT]
,[VECHICLE_TXT]
,[VEHICLE_DESC]
,[VEHICLE_CD]
,[CODE_DESC]
,[POLICY_ID]
,[POLICY_NBR]
,[STATE_CD]
,[AGENT_NBR]
,[AGENT_NM]
,[PROP_ID]
,[WRITTEN_DT]
,[PURCHASE_DT]
,[SUSP_IND]
,[SUSPEND_DT]
,[BIND_ID]
,[INSURED_NM]
,[CHANGEDBY_ID]
table 2 structure;
[REPORT_DT]
,[AGENT_NBR]
,[TRR_TOTALPIF_CNT]
,[TRR_TOTALPON_CNT]
,[TRR_TOTALREV_CNT]
,[TRR_TOTALERR_CNT]
This is the invalid output...
UPDATED
I created two datasets to demonstrate you a solution
dataset1
dataset 2
Connecting both datasets in Tableau.
I built a view in tableau as (Note policies field blue color as it has been converted to dimension)
Now calculate a field as
ATTR({FIXED [Agent code]: count([Policy no])}/[Policies])
Adding this to viz gives me
wherein desired percentages are displayed.
Note- since the tables have one-to-many relationships fixed statement in respect of measure on lesser side of relationship will also result in same result.
ATTR({FIXED [Agent code]: count([Policy no])}/
{FIXED [Agent code]: AVG([Policies])})
Here is the result set I want to get (from old report): Customer parameter is set to select all, in case anyone had questions about that field.
.....
As you can see, the report works so that each customer is grouped under a given salesperson and a total tally is at the bottom.
My problem is that this is the result I keep getting when trying to replicate this result in my new report (values aside, I know I can clean those up in the properties):
How do I do the grouping so that my subtotals, per customer, are reflected in a grand total at the bottom (in yellow)? I can do this easily in SQL, but getting it to work in report builder is what's driving me nuts lol
I have a problem that i am not able to fix.
I have a table like this
i want the output to be like this (NOT this, look at the revised result image):
is this possible with T-SQL? maybe with Excel?
There are 140 categories and approx. 60.000 rows.
Edit:
Just to clarify. I want an amount column for every category column. So if there are 140 categories, i want 140 amount columns. If there is no amount for a given category, it just going to null or amount =0.
EDIT2:
Revised result:
You can use pivot and dynamic query to generate into columns.. I just gave a sample with 2 categories you can generate the complete list using your table
select * from #yourcustomer
pivot (sum(amount) for category_name in ([cat1],[cat2] --,all categories list generated based on yourtable..........
)) p
I'm fairly new to SQL and I have been issued my first report to build. I have written an SQL query to give me a set of results that I would like to publish in a report.
I have unioned about 20 small queries all containing the correct amount of columns. One column is a misc column with about 15 different descriptions in (this is what I want to count).
I have uploaded my data set and now want to be able to choose a cell in my report to bring back a certain description.
At the minute I'm using
=count(fields!misc.values)
and it's giving me the whole count, about 200.
I would like to know if there is any kind of "where clause" (filter) which I can use to state which description results I want to bring back.
You can use am expression to count the misc.value you need. It will work like a count using a where clause:
=Sum(iif(Fields!misc.Value ="Some description",1,0))
Example:
For count the FSMethod with MethodOne as value I used this expression:
=Sum(iif(Fields!FSMethod.Value ="MethodOne",1,0))
Note the expression sums by 1 if the FSMethod.Value is MethodOne.
For count the rows with FSMethod column with MethodTwo value.
=Sum(iif(Fields!FSMethod.Value ="MethodTwo",1,0))
Let me know if this can help you.
I have a report I created in SSRS. I have it grouped by a column. The Column it is grouped by there are description, details and a date for each.
I want to try and find a datediff between two descriptions for the group but I can't seem to get it right.
I tried to do ::
=DateDiff(dateinterval.Minute,(Fields!date.Value=(Fields!description.Value="description1")),(Fields!date.Value=(Fields!description.Value="description2")))
but it errors out. any idea ? I can supply the code or screenshot if it doesn't make sense.
Try this:
=DateDiff(DateInterval.Minute
,lookup("description1",Fields!description.Value,Fields!date.Value,"DataSet1")
,lookup("description2",Fields!description.Value,Fields!date.Value,"DataSet1"))
Let me know if this was helpful.