How do I create alphanumeric measure in SQL Server Analysis Services? - sql-server

In SQL Server Analysis Services, I want to convert the column T DATA into a measure. However, the column T DATA is nvarchar(120), which confuses me because I believe I can only convert numeric values.
To create and add all of my measures, I have created a numeric and integer type column in a dimension called PROJECT Measures.
ALTER view [tabular].[PROJECT_Measures]
as
select top 0 Measure_Project_Con_Det = 0.,
Measure_Project_Invoicing_Plan = 0,
Measure_Leegoo_Builder = 0.,
Measure_Project_Sub_Project = 0.,
GO
Now I want to modify this view by adding a new column called LB Wert into which I will insert values from T DATA. Then, in Visual Studio, create a command that calls the T Data column in LB Wert. I have no clue how to do any of this.
Any ideas?
Edit --
So for example,
enter image description here
In above image you can see 2 columns Attribute Name and Tdata. In Tdata column, the values are text or numbers. However, I want to use this column as a Measure. Now, when I try to make a measure in Visual Studio, I get Sum, count and other options and I don't think these are helpful.
enter image description here
Outcome,
enter image description here
In above image, as you can see, I have used Sum in some columns, to use them as a Measure. However, it is only possible for numbers. And I want to use these measures in Excel, Analysis Service. For example, below image.
enter image description here
In short, I want to use Tdata column as a Measure. But, I don't want to count or sum function.
I hope I am clear and sorry for confusion.

Related

Power BI - Show all data from table1 in a visual from two many to many related tables when one other field from table2 on the X-axis

I have a key column in two many to many related table and sample representation of data is -
(attaching sample version of the table to get the point across as there are other numerous columns not contributing to this visual)
table 1 -
table 2 -
I am making a line graph with date on x axis and the value1 and value 2 on y-axis. The value1 is true for all dates. It is basically a standard target value. Now I want all the value1 summed up to show in my visual as value1 and not just the ones for which I have data on those dates. To explain it better I want 1717 on the graph as well like the total in the table in the following image -
visual -
Is there a way to do this in power BI? I tried to make a shared dimension of all unique key as a separate table and connecting both the tables to that table but there is no change in visual due to that.
You can follow these below steps to achieve your required output-
Step-1 Create a custom column in your *table 1 as below-
value_1_sum =
CALCULATE(
SUM(table_2[value1]),
ALL(table_2)
)
Step-2 Configure your line chart as below. Remember, the aggregation for new custom column will be Average as shown in the image
And here below is the final output-
Additional Reference Here below is list of options you will get after right click on the measure name-

how to format the specified cell value in two different formats in SSRS Report

I have SSRS report data where we will have two different thing in some of the cells, For example:
Old Values in SourceDB
FirstName LastName
Robin Son
BOB Alice
Updating the DB values:
FirstName LastName
Robin S
BOB A
After some update, we will have the changes and new & old values in Audit Table so the report will be created like this.
FirstName LastName
Robin was: Son now: S
BOB Was: Allice now: A
Is it possible to have the Was value in Red color and the now value in Green Color.
In worst case if it is not possible how to make the whole cell value into red.
Thanks for the suggestions or answers or even feedback's are appreciated.
If you can't change your Audit table per Ashiko's very sensible recommendation to hold the Was and Now values in seperate columns, you will need to parse out the relevant parts of your string value in your report.
One way you can do this is through placeholders that have expression based values. In your SSRS table, add 4 placeholders to a table that is based on your Audit dataset, with the following expressions as their Label and Value:
Was: - ="Was: "
Old Value - =replace(left(Fields!LastName.Value,instr(Fields!LastName.Value," Now:")-1),"Was: ","")
Now: - ="Now: "
New Value - =mid(Fields!LastName.Value,instrrev(Fields!LastName.Value,":")+2,99999)
You can then format the individual placeholder items as you would normal text, with some one colour and others another.
If you do this correctly, you should end up with something like this:
Design View:
Rendered:
Do be aware though, that if you do resort to splitting your string values in this manner, if that pattern you are searching for (eg: Now: in the old value or : in your new value) you will get undesirable results in your report.
If this is an entirely internal report for monitoring purposes, this is probably not an issue. If this will be customer facing however, I strongly recommend that you add additional columns to your Audit table for the Old and New value to allow you absolute control.
Did you try this?
Select the cell
Click F4 to open cell properties or right click the properties
In font tab , Select Color
4 Select Underneath Expression
5 Write as
=iif(Fields!ColumnName.Value = "WAS","Red","Green")

SSAS: How to preserve null value in microsoft BIDS

I am trying to create a cube in microsoft analysis services, but i failed to preserve the null values. It always return as 0. In my database (SQL Server 2005) i have two fact tables and two dimension table and a date table. In my fact table I have 0 values, null values and some positive values.
Here is what i have done so far
In the above picture the values for Bigeye tuna and other tuna is null, but it is showing as 0, the value for EEZ is 0 in the database and it is shown correct. I have set nullprocessing to preserve as shown below
When I set # as the format string the value for EEZ is also gone.
Here is the database table
I want it to show the value of EEZ(11) as 0, and remove the values of Bigeye Tuna(9) and other tuna(10) as it is null in the database also.
So can anyone tell me how can I accomplish this?
This should work w/o additional format settings. Are you sure there are no mixed values 0 and NULLs?
Here is my example, last column is a source for fake measure with zeros and NULLs:
Here is measure settings w/o format:
Finally, here is browser with empty cells turned on:
Everything should work as above.
Maybe it's connected with hidden level. Could you temporary turn EEZ lower level back and see value there?
Grand total shows zeros in Excel instead of 10.3K, 104.5K and 114.8K. Is there some SCOPE, which manage totals or other parts?
And also please check mixed 0 and NULL values for the same group/member.

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.

How to add an non aggregated column in a fact table?

I'm working on a SSAS cube to allow user to analyze some sales.
So, I created a fact table to record all sales and few dimensions to browse inside data (category / location & store, etc...).
This is a example of the fact table output (from SQL Server Management Studio) :
When I browse my cube, I can review all sales including date, quantity, etc.
However, when I add some fields like the "unit price" or the "unit cost", it returns me a strange result probably due to an aggregate behavior.
It seems it return the sum of all matching rows (aggregateFunction property).
How to simply display the unit price of a sale without apply any calculation to the unit price column. The None value for the AttributeFunction display BLANK/NULL.
If your unitCost and unitPrice are the same for each product (I mean unitCost can be only 77.6 for product_id = 2), you can just use average (or even emulate average by SUM/COUNT) - but only for product dimension on axis!
Another dimensions will show real average values.
Maybe it's better to use this 'static' fields like attribute properties in 'Product' dimension? But you still need to add some logic to choose one value for several (or all) product members selected.

Resources