DAX - IF lookup value empty return column value - powerpivot

I'm using Power Pivot 2013, I have two table.
(fact)Table A: Name and Value
(dim) Table B: Name and Type
When selecting pivottable, I want to show Type and Value but if Name.TableA can't be found in Name.TableB, instead of returning (blank) i want pivottable to return Name.TableA. I have tried VALUES() IF(VALUES) with no success.
Thank you in advance.

i think that you have created a relation between name.tableA and name.TableB. You can Create a calculated column on TABLEA using related(Type.TableB).
At this point if you have a relation between the table in new column on TableA you have some row blank and some row with the TYpe.TableB. If it's working change the column formula with
=if(ISBLANK(related('TableB'[Type]));'tableA'[name];related('TableB'[Type]))
If there isn't a connection between table you should change related with Lookup.

I use a named variable inside the measure for that:
var mylookup = LOOKUPVALUE(
dim[name]
, dim[id]
, fact_table[id]
)
return IF( NOT ISBLANK (mylookup), mylookup, "UFO")
UFO value will be returned either:
if dim table contains NULL in the dim[name] field,
if there is no match for [id] in dim table.
See more DAX VAR defining named variables in the middle of the measure code

Related

Replacing multiple null value columns with blank in tableau

I have data source which consist of 16 columns. Many of these columns consist of null values. I have to replace null value columns with blank (all columns at a time).
When I surfed on internet I got one solution as create calculated field to replace null values using IFNULL() function. If I'll use this solution then I've to create 16 calculated fields for every single column.
Is there any solution so that I can replace all null columns with blank simultaneously? Is there any GLOBAL setting which will help me to achieve this?
Thank you.
BLANK is the default replacement for NULL in Tableau.
You can set how Tableau treats NULLs by measure:
Right-Click the measure and select 'Format':
On the left, you will see "Special Values" section:
Set the test to whatever you want.
Use LOOKUP() function, for the columns where values are present, it shows the value else blank or '-'.
For e.g LOOKUP(SUM(Sales) , 0)
for null

Replace null with zero in crosstab query in Telerik

I just created 2 cross table using wizard function of Telerik Standalone report designer tool
since ISCED 5 has values for private and public its showing properly
using same query I created second cross tab and
but since ISCED 6 table doesnt have values for "public" section its showing like this
how to show as zero for public section 2nd cross tab (when no values for specific row)
You should modify the value of the field using an expression to evaluate your condition.
Select the textbox containing the data corresponding to the column you like to format when the value is null.
In the property pan on the right select "Value"
Write in there your expression, it should be something like this:
=Iif(Fields.MyField IS Null,"0",Fields.MyField)
You should also consider if the value instead of null is empty and eventually cover this case in the expression if applicable.
= Iif(Fields.MyField IS Null OR Fields.MyField = "", "0", Fields.MyField)
More information on conditional formatting can be found here.
Let us know if this works for you.

How to create list as a parameter in SSRS?

I have a report in 2005 SSRS which I want to add a parameter to. The parameter would be comprised of a group of zip codes, but be selected as a single item in the list.
For example, I would like to have 5 zip codes as one selection in the list and 3 for another, etc:
Select 11111,22222,33333,44444,55555,66666 AS Boondock
Select 77777,88888,99999 AS Timbuck
Select Zip Codes NOT IN (11111-99999) AS Everything Else
So my selections in the dropdown would be:
Boondock
Timbuck
Everything Else
Can anyone help me with how I should go about creating this parameter?
Create a simple string parameter to present to the user. Let's call it ZipCodeSet.
Create a dataset that examines the #ZipCodeSet parameter and returns the appropriate list of zip codes. Call it ZipCodeSelection.
Create an internal multivaue parameter that uses ZipCodeSelection as both its Available Values and Default Values. Call it SelectedZipCodes.
Use SelectedZipCodes in your report's datasets.
The easiest solution here would probably to use a Calculated Field on your dataset, called LocationDescription, for example:
=SWITCH(Fields!ZipCode >= 11111 and Fields!ZipCode <= 66666, "Boondock", Fields!ZipCode >= 77777 and Fields!ZipCode <= 99999, "Timbuck",True, "Everywhere Else")
The lone true statement at the end is due to the SWITCH expression reading left-to-right and exiting once it evaluates one of the switches as TRUE. This way for each of the items in your table of ZipCodes you will always end up with a TRUE result.
I assume you're evaluating a range of ZipCodes, and not exact values of 11111,22222, and so on? If so, the switch will have more values. A sample of your data would help if you want an exact answer.
Once you have built your Calculated Field, you can then set up a Parameter (called #LocationParameter) with available values based on a query of your LocationDescription field, then just filter your dataset using:
Expression:
= Fields!LocationDescription
Operator: =
Value:
#LocationParameter
(if you want multiple selections on your parameter, change the operator to IN)
Hope that helps.

SSIS New Column with Condition

I have Created one new column using Derived column Record_Type as (DT_WSTR,25)"" data type, Then I used another derived column to create my condition for Record_Type is PRDCT_IND == TRUE ? "PRIME" : "SEC".
Can it be possible to create both the thing in one derived column?
Appreciate your help.
343
It appears you are trying to create a column with a conditional as the data that is defined as a DT_WSTR,25, so you could create it all in one step with the following:
(DT_WSTR,25)(PRDCT_IND == TRUE ? "PRIME" : "SEC")
first set of () casts the entire result to a DT_WSTR of length 25
second set of () uses the value of PRDCT_IND to set the value to either "PRIME" or "SEC"
Simple answer: no.
You can't use the columns created in a component within the same component.
You'll have to add a second derived column component.

How to exclude one value from a grouping sum, based on a value of another field?

How do I exclude one value from a grouping sum, based on a value of another field?
ie I open Report=> Report Properties=>Code and insert my Custom Code, but how would I change the below code to exclude a numeric value of another field for the below case?
Public Function ChangeWord(ByVal s As String) As String
Dim strBuilder As New System.Text.StringBuilder(s)
If s.Contains("Others") Then
strBuilder.Replace("Others", "Other NOT INCL")
Return strBuilder.ToString()
Else : Return s
End If
End Function
I'm assuming you want to exclude a numeric value from a sum where the string value of a cell on the same row includes "Others", and that the function you've supplied is used as the grouping criteria for a table in the report. Apologies if this isn't correct.
It's not going to be possible to do this without using a second piece of logic, either a function or an Iif condition. I don't have SSRS available to test this at the moment, but (assuming your value column is an integer, the code will look something like:
Public Function ExcludeOthers(rowDesc As String, rowVal as integer)
if ChangeWord(rowDesc) = "Other NOT INCL"
Return 0
else
Return rowVal
end if
End Function
Then, in the cell where you want the conditional sum to appear:
=Sum(ExcludeOthers(Fields!desc.Value,Fields!val.Value))
Alternatively, you could do this without the function by using Iif in the cell where the conditional sum will appear:
=Sum(Iif(ChangeWord(Fields!desc.Value) = "Other NOT INCL",0,Fields!desc.Value))
Depending on the nature of your source data, you could also do this by adding calculated columns to the report's source query.
I would favour the second or third option - custom code seems like overkill for this purpose.