MDX - How to know if a measure has been pivoted with a dimension? - sql-server

I was hoping someone could help me with this problem.
In a sum type measure, i need to know if this measure has been pivoted with my time dimension. If is not, the measure must show the sum of the last day. In other case, the measure must show the sum of the day with has been pivoted.
I have the measure "Users", if this measure hasn't been pivoted with my time dimensiĆ³n, it shows the sum of all users of all the time. For example it shows: 5,000,000. When it has pivoted with the time dimension, it shows de users from the day. For example: 100,000 for today 21/05/2015.
When this measure hasn't been pivoted with the "time" dimension, the measure must show 100,000 and not the total sum of all days.
I've been trying white some MDX formulas but i have not found some solution for this.
Thanks

I've interpreted this as when pulling your Users measure without pivoting on the Time dimension you would prefer to see the value that corresponds to the current date.
This can be achieved by modifying the Default Member of your Time dimension. Setting the default date to this last available date
Within your Dimension in SSAS, browse to the Dimension Structure tab and select the attribute which represents the key column (ie. the Usage property is set to Key for only one column)
Within the Properties pane (strike F4 if you do not see it already to open it) select the Default Member property, then select the elipses (...)
The Set Default Member - [Dimension Name] pane will have 3 options, select the last Enter an MDC expression that specifies the default member
Use ONE of the following expressions
TAIL([Date].[DateAttribute].Members).Item(0)
TAIL(NONEMPTY([Date].[DateAttribute].Members)).Item(0)
TAIL(EXCEPT([Date].[Date].Members,{[Date].[Date].[Unknown]}),1).Item(0)
In my case I used the last as I only want to exclude my UnknownMember member
Now when you pull the measure down the value will be for the last date in your cube. This will affect other cubes built on this date dimension of course.

Related

How do I create a default everyday date dimension?

I am trying to create a line chart counting all the optins per date, however the only dimension that is will allow me to choose from have to be a date column on my source. The problem with this is it only chooses from dates that are populated in those fields with an optin date.
For example: I have 5 optins on 1/1/2019, 0 on 1/2/2019, and 3 on 1/3/2019
If I use this series and want to include another metric, 1/2/2019 will not show anything for that other metric
I just want a standard everyday series that counts every metric on a given day. The google analytics connection source has a generic Date dimension but I can not figure out how it was done
Ive tried creating a new column with everydate on it and trying to use that as a dimension without any luck
You should be able to use a Time Series graph (of which there are 3 types) instead of a Line graph.
A Time Series will keep the days where no data is available unlike the Line Graph which only presents labels for those which have values in the data.

How can I split data from a second dataset in SSRS

I have two tables in SSRS. One holds the amount of insurance claims in a given month and one holds the amount of insurance complaints in a given month
Each table is calculated by either =COUNT(Fields!Claims.Value) for claims and =COUNT(Fields!Complaints.Value) that is simple enough and is split over the current 10 months of a year
Where it gets tricky though is that the claims table has an additional line where it calculates complaints as a ratio of claims. My current expression reads as follows:
=COUNT(Fields!Complaints.Value, "Complaints"/=COUNT(Fields!Claims.Value)
but the problem I have is that it's taking the full YTD value of the complaints and dividing by the monthly amount of claims.
ASK:
How can I get a calculation similar to above but only dividing complaints by month and claims by month - but keeping in mind that the complaints data comes from a different table
You can use LookupSet function to get the claims in the same month.
Create a tablix and use the Complaints dataset in the DataSetName property.
Add Month as Row Group.
For complaints column use:
=Count(Fields!Complaints.Value)
For claims column use:
=LookupSet(Fields!Month.Value,Fields!Month.Value,Fields!Claims.Value,"Claims").Length
For Ratio column use:
=IIF(
ReportItems!Textbox69.Value=0,0,
Count(Fields!Complaints.Value)/ReportItems!Textbox69.Value
)
Replace Textbox69 by the name of the textbox where Claims (LookupSet) expression is placed.
Note the validation for zero denominator in case there is no claims in a given month.
It should produce:
Let me know if this helps.

SSRS Conditional Expression

In SSRS report, I want to perform conditional color formatting where highest rank should be Green and lowest rank should be Red within a Regional Manager group as shown below
Note: Couple of options, I was thinking of includes
I am using custom code function, for deriving Min and Max value, and somehow if I can include grouping filter on Regional Manger then it could work, but don't know if that's possible
In dataset, I create extra columns for each column and store Min\max value in it. But less keen towards this option, since I have 24 different ranks and which would mean, I will need 24 different columns along with current 40 attributes
Any help would be appreciated
I know you don't want to do this for each column, but despite your misgivings it is probably the best approach. Based on my previous answer to your earlier related question you can colour the min and max for each group as follows.
Create a table with fields store, atvrank, and btvrank
Right click the row header, and select Add Group -> Row Group - Parent Group, and choose Regional Manager. Set the Group name to RegionalManagerGroup
Then set the background colour for your cells to
=iif(Fields!atvRank.Value = min(Fields!atvRank.Value, "RegionalManagerGroup"),
"Green",
iif(Fields!atvRank.Value = max(Fields!atvRank.Value, "RegionalManagerGroup"),
"Red",
"White"
)
)
This now finds the maximum and minimum within the current group instead of the whole dataset. You will need to set this expression for each field individually, but this is probably less effort than returning new rows from the database to determine the maximum and minimum for each field.
This approach will give the following output
Please seriously consider this solution. If you have further questions, please just ask.

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]) )

Hide a row in Excel OLAP pivot table

I have an Excel sheet which connects to a cube. The information is presented in a pivot table. The problem is that I need to hide one member of the dimension on the rows axis.
That is I have the following table.
a value1
b value2
c value3
total
I want to hide the row with value b. I cannot solve this with filters in the pivot table since the member must always be hidden and if the filter is used then a user can select it.
What I have tried so far:
Use a named set with an MDX calculation. This does not work since a named set cannot be used in filters.
Use a calculated measure IIF(currentmember = b, null, value). This does not work since the grand total still includes the value for b.
Any suggestions? I prefer not to create a scoped member in the cube specifically for this report.
In case anyone is still interested I found a solution to the problem.
Created a new measure in the cube with a null value.
Created a scope calculation for the measure in the cube, IIF(currentmember = b, null, value).
Created a new perspective in the cube list where the new measure is not visible.
Lots of work but I could not find any other options in this case.
I've searched high and low for this answer.
I had a similar issue. I was trying to calculate a measure from other 3 measures then filter and aggregate the filtered result. I came up with this:
Calculate the column in the source view table ( a - b + c = x)
Add the unfiltered calculated column (x) to the dsv
Create a named calculation in the dsv that uses a case statement to filter the original calc measure
Add the named calculation as measure
I choose to do it this way to capture the measure unfiltered first then, if another filter needs to be added or one needs to be taken off I can do so without messing with the views again. I just add the new dim to filter by to my named calculation case statement.

Resources