I'm trying to generate a sequence of numbers in a calculated table for a SSAS 2016 1200 Tabular model.
What i'm trying to achieve is is to generate number sequence like 1,2,3..100 in a single column. Just like the GENERATESERIES() DAX function does, but it is only available in SSAS 2017 and onward.
Is there a good a simple way to achieve the same thing in SSAS 2016?
Yes, in SSAS 2016 you can use CALENDAR and then cast the Date to an int, like for instance
EVALUATE
SELECTCOLUMNS ( CALENDAR ( 1, 100 ), "Value", INT ( [Date] ) )
here is the link to a working implementation on dax.do
Related
This is a question regarding SSAS Cubes, MDX formulas and Power BI.
I have a measure with the active members per each month. So when I select for example 2018 it shouldn´t aggregate but return the last available month with active members, and if I break down by month it should give the active members for each month.
So I have this formula which works almost fine if querying in MS Management Studio:
with member [Measures].[Last existing SOCIOS] AS
Max(
EXISTING [DIM FECHA].[Jerarquía].[MES NOMBRE].members,
iif([Measures].[ACTIVOS] = 0,null,
[Measures].[ACTIVOS])
)
select {[Measures].[Last existing SOCIOS]} on columns,
[DIM FECHA].[MES NOMBRE].members on rows
from [cubo_Compromisos]
where [DIM FECHA].[AÑO].&[2018]
I would prefer to have the november value returned at the 'All' level. But this is not my main problem. The real issue is that when I use this measure in Power BI it behaves differently: when selecting multiple months it ignores the selected values and just returns the last value for the whole year.
In the screenshot below I have added the value returned by the KPI Card because that is the value that I want returned:
If I select items like this it does it right, but I need it to select all months, and not just one because I am using this measure along others:
Does anyone know the right MDX function to use or an alternative?
Edited: 23-11-2018
It does the same in a Pivot Table connected to a SSAS Cube.When I add the date dimension to the table it works fine. But when using the date dimension and filtering it without the dimension added as rows it returns the value for the whole year.
The function you are looking at is LastChild. Last Child on the upper level of the hierarchy will return the value you are looking at.
I think that function can be used in the Cube design in SSAS - then this will be the standard behavior. If you want to do it with a query you need to do something like:
SELECT [Date].[Fiscal].[Fiscal Quarter].[Q1 FY 2002].LastChild ON 0
FROM [Adventure Works]
To get the last month of the 1st quater (I used example from microsoft and another post on the subject )
I am trying to create dynamic Time Intelligence in SSAS Tabular similar to traditional OLAP Time Intel.
Additionally, I need Time Intelligence that can handle two sets of date hierarchies. For example, a Transmission Date and an Activity Date.
For example, I am trying to create a simple year-to-date sum of gross sales given that the user has selected two filters in an Excel pivot table. We are talking about all dates of transmission but only from the point of view of a single activity date. That is, I want to view 2016 total sales as if it were today, but also as if it were last month (i.e. as of a month ago, what did sales look like?).
An additional caveat is that I need two special calendars: a radio broadcast calendar for the transmission period and a traditional gregorian for the activity period.
I have started here:
YTD :=
IF (HASONEVALUE ( Dates[Years-Bcast] ),
CALCULATE (
SUM ( Sales[Sales Amount] ),
FILTER (
ALL( Dates ),Dates[Years-Bcast] = VALUES ( Dates[Years-Bcast] )
&& Dates[DatesKey] <= MAX ( Dates[DatesKey] )
)
),
BLANK ()
)
The problem I assume is my filter; I really want the last FILTER clause to be:
&& Dates[ActivityDateKey] <= MAX ( Dates[DatesKey] )
The activity date would be a user-defined report filter. It seems I need 2 filters. The first filter is filtering out only the applicable transmission dates I need, so then my activity date filter is pointless.
Any help would be greatly appreciated.
this might be what you're looking for..
KEEPFILTERS - https://msdn.microsoft.com/en-us/library/hh758426.aspx
I have a dimension [Date].[Last Met].
I need to pull out values which are more than 90 days from current date using MDX.
Please suggest the best way.
You can filter like this:
FILTER
(
[Date].[Last Met].MEMBERS,
Datediff("d",[Date].[Last Met].CurrentMember.Name, Format(Now(),'yyyyMMdd') <=90
)
A much more elegant option would be to create a calculated column in DSV called RollingLast90Days, and using SQL datediff logic to assign it 1/0. Once in place, you would need to just have a slicer :
...WHERE ([Time].[[RollingLast90Days].&[1])
Above is based on asumption you would process cube daily. If not apply the same logic in a calculated measure.
IIF(
Datediff("d",[Date].[Last Met].CurrentMember.Name, Format(Now(),'yyyyMMdd') <=90,
1,
null)
and then using this slicer on HAVING or in WHERE clause.
I have a cube fact table for targets, the targets are at the monthly level (Jan = 300, Feb = 450, Mar = 350 etc.)
This is joined to the date dimension in my cube at using month as the join, however the dimensions grain is at the day level.
What I want to do is create a calculation so that the monthly target is allocated evenly to the days in the month so each day in Jan has a target of 300/31 Feb 450/28 etc.
I then want to be able to use this calculated measure as my target and have it available as the daily/monthly/quarterly/Annual Target.
I think this should be possible with an MDX statement (or perhaps a few using a few calculated measures) but I'm not that familiar with it.
So would this approach work and what would the mdx look like?
Thanks
If you have the ability to make changes to your source OLTP/staging database, then it would be best to change the grain of your Targets fact table to daily if you need to report at that level. You could do this with a view if you have a date dimension table in your OLTP database by joining your monthly fact table to your date dimension on the month attribute, and then evenly distributing the target value over the days of the month.
If you are using SQL Server and your OLTP schema looks like the following:
CREATE TABLE dimDate (
Date Date,
YearMonth Integer,
...
)
CREATE TABLE factMonthlyTarget (
YearMonth Integer,
Value Integer,
...
)
Your new fact view would be something like the following:
CREATE VIEW factDailyTarget AS
SELECT
dimDate.Date,
factMonthlyTarget.Value / Months.DaysPerMonth AS Value
FROM
factMonthlyTarget,
dimDate,
(
SELECT YearMonth, COUNT(*) AS DaysPerMonth
FROM dimDate
GROUP BY YearMonth
) Months
WHERE factMonthlyTarget.YearMonth = Months.YearMonth
AND Months.YearMonth = dimDate.YearMonth
I have a cube in my sql server analysis service (2012) project. One of my measures is withdrawn money from ATM. Now I want to have a new calculated measure that show me the growth of withdrawn money today toward to last day. It is a dynamic calculated measure.
Is there any solution for doing this work?
What you are looking for is most probably called a KPI = key performance indicator. Look here for information about how to add the metric you need.
if you want to show growth based on last value, for example today I Withdrew 10% less than yesterday, yo ucan use KIPs
if you want to show how much you Withdrew so far, you should use calculatins like YTD (year to date)
You should use KPI to build your measure.
Open your SSAS project in Visual Studio and double click on your cube.
In the KPI tab there is a panel with some samples of KPI using parallel periods.
This is an example to create an operating margin accross two periods :
IIf
(
KPIValue( "Gross Profit Margin" ) >
( KPIValue( "Gross Profit Margin" ),
ParallelPeriod
(
[<<Time Dimension Name>>].[<<Time Hierarchy Name>>].[<<Time Year Level Name>>],
1,
[<<Time Dimension Name>>].[<<Time Hierarchy Name>>].CurrentMember
)
), 1, -1
)