SSAS finding data with date lower or equal to selected - pivot-table

I have SSAS cube and Excel reports based on it. Now I need to show all data with date lower or equal date pointed in filter in Excel. I can do it in DAX but I have no idea if it is even possible in SSAS/MDX. Maybe there is some way to use filter value in MDX measure? It seems to be pretty often problem but I can't find any solution.

You can use MDX order function:
Order
(
{
//your set
},
[Measures].[Measure],//measure to order
DESC //Order type
)
https://learn.microsoft.com/en-us/sql/mdx/order-mdx?view=sql-server-ver15

Related

How Can I get Tableau to just Pull a Specific Data Point

I am new to Tableau and am trying to figure out how to isolate a row of data in a calculated field.
For example, to get a certain piece of data for a certain year only and then use that for calculations.
I want to find the percentage change using a calculated field between undocumented immigration growth from 2000-2010-2018.
I have tried the following to just try to isolate the value point for 2018:
(IF STR([Year])='2018' THEN [Undocmented Population] ELSE NULL end)
and also this but it needs to be aggregate measures:
{ FIXED [State]: IF STR([Year])='2018' THEN [Undocmented Population] ELSE NULL end}
I just want to isolate the date points for the various years per state so then I can perform a simple change in percentage calculation and cannot seem to figure out how to do it...
Tableau Excerpt

SSAS cube and getting data with MDX for SSRS report

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

Ssrs reports Windows 2008

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.

setting last child in dax tabular

Balance:=CALCULATE(SUM(Fact[Local]), 'select'[select Type]= "ACTION")
In Multidiemnsional model I could just select Aggregate Function as Last Child in the properties, but I what should do in the tabular in order to get the last child?
Or If I have to write a dax formula what should I add from formula above?
Assuming you have a continuous date table, the equivalent in DAX to LastChild is
CALCULATE ([Measure], LASTDATE(DateTable[Date]))
If you don't have a continuous date table (i.e. you're using a degenerative date dimension, etc.) you'd use
CALCULATE ([Measure], LASTNONBLANK(TableWithDate[Date], [Measure]))
UPDATE: With DAX, it's almost always better to create intermediate measures to build up to your final measure for reuse, maintainability, debugging, etc.
So first just use your existing Balance measure
Balance:=CALCULATE(SUM(Fact[Local]), 'select'[select Type]= "ACTION")
Then do
LastBalance:=CALCULATE([Balance], LASTNONBLANK(CalendarMonth[MonthKey], [Balance]) )

SSAS 2012 DAX SamePeriodLastYear() with Date Dimension

I have a date dimension and a fact table. I have two measures:
WorkOrdersCount:=
count(
FactWorkOrderLifeCycle[Clientsid]
)
and
WorkOrdersLastYearCount:=
CALCULATE(
count(FactWorkOrderLifeCycle[Clientsid]),
SAMEPERIODLASTYEAR(DimDate[FullDate])
)
WorkOrdersCount is simple and works fine. I thought WorkOrdersLastYearCount would be simple as well, but I now realize I don't understand SAMEPERIODLASTYEAR().
My date dimension has a DateSID column containing an integer representation of date as YYYYMMDD. It has two recordkeeping rows with SIDs of -1 and -2 for unknown and TBD dates. I'm only using the -1 row in this solution. The data is stored in a SQL Server table and the FullDate column is a "date" type. The actual value is 1900-01-01.
My fact, FactWorkOrderLifecycle, has a field called InvoicedDateSID that can have a null value which I replace with -1.
No errors are thrown in Visual Studio or when processing the olap, but upon referencing the column in a pivot table I get the following error:
ERROR - CALCULATION ABORTED: Calculation error in measure
'FactWorkOrderLifeCycle'[WorkOrdersLastYearCount]: An invalid numeric
representation of a date value was encountered.
Things I've tried (not all make sense):
changed SID values to positive integers
changed date value in dimdate to 9999-12-31 instead of 1900-01-01 when I saw that DAX dates might start at 1900-03-01
adding other dimensions to the pivot first to see if the formula calculates correctly at all.
I'm a DAX noob and I'm not sure how to troubleshoot this. Any help is appreciated!
Make sure you calendar table is indeed using a Date data type.
Remove any time component of your dates.
Make sure there are no gaps and no duplicates in your Calendar table.
Make sure you are using fields from your Calendar table on the pivot, and NOT date related fields from your data table.

Resources