Problem with SSAS ParallelPeriod and Excel 2013 Timeline Filter - excel

Currently i had a project using Microsoft SQL Server Analysis Service. I found a problem regarding filtering data with excel timeline.
Here is my date dimension screenshot:
<img src="https://i.stack.imgur.com/NUr2x.png"/><img src="https://i.stack.imgur.com/5OSgA.png" />
I had a cube with 2 measures, Sales Quantity (measures) and Sales Quantity Last Year (calculation). Here is MDX expression for Sales Quantity Last Year calculation:
( ParallelPeriod([Date].[YM].[Calendar Year],1,[Date].[YM].CurrentMember),[Measures].[Sales Quantity In 1000] )
After deploying the project to my local server, the data can be shown perfectly using excel 2013:
Pic: Data in Excel without filter
The problem start when i want to filter the data using excel timeline. When i filter only '2016', my calculation measure is no longer working. You can see the data in 'Sales Quantity in 1000 LY' column is blank. It looks like that i cant see the data outside current filter (2016). Pic: Filtered using timeline filter
But when i use slicer, the data can be shown normally Pic:Filtered using Slicer
Did i make a mistake in building date dimension? Or i need to fix the MDX calculation query? Because when i test this case in Microsoft AdventureWorksDW2014 with the same date hierarchy and the same calculation, all is going well.

Your parallel period calculation looks correct assuming [Date].[YM] is your date hierarchy. I am guessing that your date dimension is off somehow.
Make sure that:
it has a hierarchy created, and the hierarchy is what you are referencing in the parallel period calculation. Here is an example, you could have more or less attributes in the hierarchy obviously.
Your attribute relationships are defined correctly.
Key columns on the attributes in the hierarchy are correct. In the example above, you would just make year the key for the year column, but then for quarter it would be a collection of the year and quarter column. For period, key columns would be year, quarter, period. For week, key columns would be year, quarter, period, week. Date would just use the date column since date is the key.
4.Make sure that the date key attribute is using a date field for it's value column, as a time slicer needs this.
define time intelligence on your date dimension. Right click on the date dimension on the solution explorer and choose add business intelligence, then on choose enhancement screen pick define dimension intelligence. Then set the attribute type for each dimension attribute. Here is how it would be for our example.
Hopefully one of these does it for you.

Related

Date table in SSAS Tabular model not working

I built an SSAS Tabular model cube and created a date table using calendarauto(). I have marked it as a date table and created a relationship with the fact table using the date column, and both columns have a Datetime data type.
When I analyze the data using excel, the date filter is not working correctly. For example, when I filter on the year 2021, it gives me row values for the year 2019 also, but if I use the date column from the fact table, I get the correct results.
When I analyze the Tabular cube using Power BI, it works right.
Could you please suggest what exactly is going wrong with our date table?
When I put the Fact table date column and date table date column on excel it looks like the screenshot below.
First, I think that is a bad IDEA to use CALENDARAUTO because it searching for all date columns from your model (and if you have a Customer with a born date eg. 1912-02-02, then you create a big table from that date).
CALENDARAUTO ignores calculated tables and calculated columns
searching for date columns. Only the imported columns are analyzed to
search for date columns.
Internally, CALENDARAUTO calls CALENDAR providing a date range that
include all the days in the range of years referenced by data in the
model, according to the following rules:
The earliest date in the model which is not in a calculated column or
calculated table is taken as the MinDate. The latest date in the model
which is not in a calculated column or calculated table is taken as
the MaxDate. The date range returned is dates between the beginning of
the fiscal year associated with MinDate and the end of the fiscal year
associated with MaxDate.
A better idea is to use CALENDAR where you have more control
CALENDAR (
DATE ( 2005, 1, 1 ),
DATE ( 2015, 12, 31 )
)
To the topic. Are you sure that you make a relationship on THIS column (in your fact table)? Check also Cross Filtering Behavior -> OnDirection/BothDirection; Show your relationship detail.

Pivot Table project - Avoid using many INDEX and MATCH functions that make Excel crash

I need some help with an Excel Project that's giving me headaches. I succeeded to achieve everything I wanted but the result is too heavy for Excel and it crashes all the time. I'm over-using the INDEX and MATCH functions on large tables (50 000+ lines) and Excel doesn't like it. I'm looking for a way to do the same thing in a lighter way for Excel.
Here's what I achieved : I created a report that helps me analyzing my employees's performance VS their billing targets. To create such a report, I used a Pivot Table.
That Pivot Table needs this information as its source :
Each sales that every employee made (amount in $ and date)
The hourly rate of each employee (which changes for every period, see TABLE1 below)
The billing target for each employees (which changes for every period, see TABLE1 below)
Here's my setup. I have 3 tables :
TABLE1 (See attached image) - A table where I manually input data for each of my employees (hourly rate and billing target). Their billing target and hourly rate change every period. So, each period has a different line and I indicate the first day of the period and the last day of the period.
TABLE2 (See attached image) - Table that contains sales data exported from another software I use. Each line represents an amount sold by an employee to a customer on a specific date. This table is pretty heavy and contains more than 50 000 lines. Moreover, the last 2 columns of this table use Index and Match functions to get the right hourly rate and the right billing target from TABLE1. That means that each of those 50 000 lines uses the INDEX and MATCH functions twice… This part is too heavy for Excel and I need a workaround.
Moreover, TABLE2 is getting refreshed every few days with new data coming from my other software (an ERP). So the solution I need to find must take that into account and must be permanent (I try to avoid steps that will have to be done everytime I refresh TABLE2 with new data).
TABLE3 - A Pivot Table that uses TABLE2 as its data source. I use the slicer to select the name of an employee and a timeline to specify which months I want to display. Then the Pivot Table shows my employee's statistics grouped by months. The main statistic is the amount of "billed hours" for each employee, which is in reality the amount of sales made by that employee, divided by their hourly rate on a specific date.
My thoughts :
It is absurd that TABLE2 uses that many INDEX and MATCH functions. For example, if Employee1 made 500 sales between 2020-07-01 and 2020-07-31 (the same month, thus the same period, thus the same hourly rate and billing target), there will be 500 different lines that will use INDEX and MATCH to get the same hourly rate and billing target from TABLE1. That leads to a lot of duplicated calculation and a lot of duplicated data.
Would it be possible for a Pivot Table Calculated Field to use INDEX and MATCH in its formula? And would it be lighter for Excel to do so?
Another way would be to add, at the bottom of TABLE2, 12 lines per year (1 for each month) for every employee where I would write their hourly rate and the billing target. That way, the Pivot Table would be able to display an hourly rate and a billing target for each month, for each employee. That solution would work and would be lighter for Excel, but it would create a high risk of making mistakes while manually inputting the data.
I'm open to all suggestions including VBA!
Thank you very much for your precious time!
EDIT : FORMULA
As requested, here's my INDEX AND MATCH formula that is in TABLE2 and gets the hourly rate from TABLE1 :
=INDEX(TAB_Employee_Data[[#All];[Hourly_Rate]];MATCH([#[Date (Cell)]]; IF(TAB_Employee_Data[[#All];[Name]]=[#[Employee(Cell)]];TAB_Employee_Data[[#All];[First day of the period]]);1))
TAB_Employee_Data is the tab that contains "TABLE1".
I translated the names of the fields since all my work is in French.
This formula does the following : it searches the name of an employee in TABLE1 and finds the period which fits the date of a line in TABLE2.
Also, to work properly, I need to sort the lines of TABLE1 in chronological order.
TABLE 1 :
TABLE 2:

Calculate average based on a value column (count) in a pivot table

I'm looking a way to add an extra column in a pivot table that that averages the sum of the count for the months ("Count of records" column) within a time period that is selected (currently 2016 - one month, 2017 - full year, 2018 - 5 month). Every month would have the same number based on the year average, needs to be dynamically changing when selecting different period: full year or for example 4 months. I need the column within the pivot table, so it could be used for a future pivot chart.
I can't simply use average as all my records appear only once and I use Count to aggregate those numbers ("Count of records" column).
My current data looks like this:
The final result should look like this:
I assume that it somehow can be done with the help of "calculated filed" option but I couldn't make it work now.
Greatly appreciate any help!
Using the DataModel (built in to Excel 2013 and later) you can write really cool formulas inside PivotTables called Measures that can do this kind of thing. Take the example below:
As you can see, the Cust Count & Average field gives a count of transactions by month but also gives the average of those monthly readings for the subtotal lines (i.e. the 2017 Total and 2018 Total lines) using the below DAX formula:
=AVERAGEX(SUMMARIZE(Table1,[Customer (Month)],"x",COUNTA(Table1[Customer])),[x])
That just says "Summarize this table by count of the customer field by month, call the resulting summarization field 'x', and then give me the average of that field x".
Because DAX measures are executed within the context of the PivotTable, you get the count that you want for months, and you get the average that you want for the yearly subtotals.
Hard to explain, but demonstrates that DAX can certainly do this for you.
See my answer at the following link for an example of how to add data to the DataModel and how to subsequently write measures:
Using the Excel SMALL function with filtering criteria AND ignoring zeros
I also recommend grabbing yourself a book called Supercharge Excel when you learn to write DAX by Matt Allington, and perhaps even taking his awesome online course, because it covers this kind of thing very well, and will save you significant head-scratching compared to going it alone.

Cognos - Showing every month on x-axis when some months don't have values

Let me first say I am very new to Cognos and have mainly learned by just manipulating items within active reports. I am having an issue with creating a graph that acts like a time series. I want it to display every month (with multiple values in some months and none in others). I want to visually see gaps between data points (ex: we order products every 3 months starting in January, so we should see gaps in the months we do not order products - like February and March).
I have tried changing the label control to manual and setting display frequency to 1. However, I think my issue is that there is not any data within certain months.
You are correct in that your problem is lack of data. A standard inner join will drop rows where there is not a corresponding row in both tables, resulting in gaps.
There are two solutions available:
Use a union to create "dummy" records for each date
Manually specify an outer join between the date table and the table containing the rest of information
Since the first technique is the most common, I'll outline the basic steps for it here.
Create a new query
Add your month data item to the query
Create a 'dummy' data item for your measure. Use 0 for its expression.
If there is a date range filter in the main query apply it here
Create a union
Drag over your new query into the union
Drag over your original query into the union
Pull in the date and measure data items into the union query
Set the Aggregate Function property of the measure to Total
Use the union query as the source for your chart
For every month with measure data you will have two rows, one with the measure amount and one with 0. The two rows will be combined by the auto-group and summarize function. The measures will be added together. Anything added to 0 will end up as the original amount.
For months with no measure data, there will only be the 'dummy' row with 0 for the measure and it will be represented in your chart.

query in a powerpivot table to do a group by

I have a table called "purchase" with the following data:
year month time day_week name provider service purchase revenue
I am using this data to make a pivot table. Then I have another table called "active":
name provider service description month year number_active
I used this data to create a separate pivot table.
Now I need a third pivot table with something like:
number_active/revenue
and slice it vertically to by year. The problem is that I cannot create a relationship between the table because in Purchase I have the services by day and hour and in Active I have the services by month. I think I need to create another table that is a view of Purchase grouped by month.
I tried the following :
home -> From Database -> From analysis services or PowerPivot
But i have a error:
I'm not sure where to go from here.
How can I make this view grouped by month?
I don't think you need to create a new view of summarized data as a source. You just need to be able to summarize by date, and you can do this by adding a date dimension.
You can download one for free from the Windows Azure marketplace.
Once you have your date table, add a calculated column to the Active table in your Power Pivot model called Date that is =[Month]&"/01/"&[year]. Then change the data type to date.
Then do the same thing to your Purchase table. Next, create relationships from Active[Date] to Date[DateKey] and from Purchase[Date] to Date[DateKey].
You could make all of this go down to the time level and related it there instead (Power Pivot will assume midnight if you don't specify a time in your date column). But I'm simplifying since that is not needed for this one scenario.
Next make your two base calculated measures
Number Active:=Sum(Active[number_active])
Total Revenue:=Sum(Purchase[revenue])
I'm not sure what your number active means, so I'm assuming it is just a sum. You can adjust this calc if this is not the case.
Then make your final calculation: Revenue Per Active User:= [Number Active]/[Total Revenue]
Then you should be able to pull month and year into a pivot table along with this new calculated measure and your original measures (number active and revenue).

Resources