ADD static table in Dax - variables

Dears
i tried to show data in power BI using a variable inside a measure but can not show more than one value.
Dax code :
Measure Not Worked : NewTable = var Data = DATATABLE("SES",STRING,{{"Name1"},{"Name2"}}) return Data
Measure Worked : NewTable = var Data = DATATABLE("SES",STRING,{{"Name1"}}) return Data
Message error : a table of multiple values was supplied where a single value was expected .
Thanks, best regards.

A measure must return a single value, not a table. (You can use tables inside of a measure though.)
If you want a static calculated table, enter it as a New Table under the Modeling tab, instead of a measure.
NewTable = DATATABLE("SES",STRING,{{"Name1"},{"Name2"}})

Related

Need a dynamic range/bucket in SSAS and would like to use it as a column in the power bi matrix

In a SSAS cube, I have a table called Workload with ID and CATG as columns.
and another table Hierarchy with ID and Name
I need output in the following way
*Range = number of DISTINCT CATG from Workload table.
I need the count of IDs from Workload based on the Range.
Can you please help me with this?
I tried to create Range as a column in the Workload table. But as it is a column and not a metric, we cant apply any other filters from other tables. If I create it as a metric, I cant use it as a column in pbi matrix.
You can do this with an additional unconnected SupportTable, where you need to store range Label, Min and Max value per range:
CountOfIDs = var _rangeMin = SELECTEDVALUE(SupportLabel[MinVal]) var
_rangeMax = SELECTEDVALUE(SupportLabel[MaxVal]) return COUNTROWS( FILTER( SUMMARIZE('Workload','Workload'[ID],"distvalperid", calculate(DISTINCTCOUNT(Workload[CTRG]) )), [distvalperid] <=
_rangeMax && [distvalperid] >= _rangeMin) )

Sum based on different column from model in Power BI

I have data from two tables modelled as follows:
my desired result is:
I've tried SUM(table1[balance],ALLEXCEPT(table1,table1[account])) - doesn't work
this may be simple, but PowerBi is evading me at this point...
Pretty simple to solve it by with extra steps to complete it:
First, on your second table (I named it "cust"), add a new column with the balance from your first table (I named it "acc"):
Balance = LOOKUPVALUE(acc[balance],acc[account ],cust[account])
Cust
Next, I will add a new column to lookupvalue on my "acc" table, follow by adding new column to return the sum value from my "cust" table:
sum = CALCULATE(SUM(cust[Balance]),FILTER(cust,cust[customer ]=EARLIER(acc[customer])))
Acc

Qlikview conditionally hide expression in pivot table

Struggling with a way to hide an expression on certain rows in my pivot table below. Basically, I want to be able to hide my expression 'Cumulative' when the FINANCIAL_PLAN_TYPE is not equal to 'OB_VARIANCE_TO_T1'. I figured out a way to change the text format on the lines with other FINANCIAL_PLAN_TYPE so that it appears hidden (what is showing in the picture below), but I'd really like the whole row to go away in these cases.
Additionally, I do not want to see a Total on the Cumulative lines if possible, but I do want to keep them on the Sum(AMOUNT) lines.
My expression for Cumulative is:
sum(aggr(Rangesum(above(sum({<YEAR={"$(vYear_Current)"},FINANCIAL_PLAN_TYPE={"OB_VARIANCE_TO_T1"}>}AMOUNT),0,MONTH_NUM)), FINANCIAL_PLAN_TYPE, MONTH_NUM))
I tried to use the function Only, as well as, I tried conditionally enabling/disabling the expression but I can't seem to get it to work. Any ideas would be great. Thanks!
FINAL SOLUTION:
1) Load Inline Table
Load * Inline
[MyDim
Cumulative
Vals
];
2) Created calculated dimension to combine the two desired dimensions into one and show blank ('') in cases that you don't want to show (this leaves one blank line on the pivot but there is probably a way to hide that too):
=If(MYDim='Cumulative' and FINANCIAL_PLAN_TYPE='OB_VARIANCE_TO_T1','Orig Budg Cumulative Variance',if(MYDim='Cumulative' and FINANCIAL_PLAN_TYPE='LE_VARIANCE_TO_T1','LE Cumulative Variance',if(MYDim <> 'Cumulative',FINANCIAL_PLAN_TYPE,'')))
3) Create a new expression that does one calculation in the case of your made up dimension = Value A and something else in case your calculated dimension = Value B
If(MYDim='Cumulative' and (FINANCIAL_PLAN_TYPE='OB_VARIANCE_TO_T1' OR FINANCIAL_PLAN_TYPE='LE_VARIANCE_TO_T1'),If(ColumnNo()=0,'',sum(aggr(Rangesum(above(sum({<YEAR={"$(vYear_Current)"}, DEPARTMENT={"20820"}, ACCT_TYPE={"Capital"}>}AMOUNT),0,MONTH_NUM)),
FINANCIAL_PLAN_TYPE, MONTH_NUM))),IF(MYDim='Vals', SUM({<ACCT_TYPE={"Capital"},DEPARTMENT={"20820"}>}AMOUNT)))
You cannot hide expression on some of the rows - not possible in Qlikview.
The workaround is to create a dummy floating table that holds the second column as a dimension and then use it in your chart instead of the two expressions. Then you will have one expression that says something like that :
If ( dummyField = 'Cummulative' and = 'OB_VARIANCE_TO_T1',
{Use your second expression here} ,
If (dummyField = 'sum(Amount)', {use your original first expression here}))
Regarding the Total, check out this link in the "Tricking the Pivot Table" section

How can I create filter based on two different fields with OR operator between them in Power View?

For example I want to filter my data based on next filter expression:
lead_veh_of_interest starts with 'BMW 1'
OR
sale_model starts with 'BMW 1'
how can I achieve this?
Are these fields both in the same table? If so you could create a calculated column that performs that conditional. Then filter the view on the resulting calculated column.
For example you could create the following calculated column.
Calculated Column: "Starts With BMW 1"
Equation:
=IF(OR(Left([lead_veh_of_interest starts], 5) = "BMW 1", Left([sale_Model], 5) = "BMW 1"), 1, 0)
Then in the view set the filter so that [Starts With BMW 1] = 1
I found acceptable solution (thanks for all suggestions - it was very helpful).
First of all I redesigned my model and (how #Mike_Honey suggsts me) created dedicated table with consolidated information I want to filter. Next I connected this new table with existing tables and created hierarchy from fields I want to give to the end users for step-wise filtering (previously I split down old fields contained information I want to filter into more granular level). Now it is possible to filter data by any combination of models in any combination of request types (sale, lead, competitor, etc) using hierarchy.

Powerpivot using If function

I have a table that contains text values in several columns. One column has a text value of either true or false. The data type of this column is Text.
Now I want to add a measure that calculates the rows where the column has a value of true. I am using an IF function:
=IF(Table[column a] = "true", COUNTROWS(DISTINCT(columnid)),0)
When doing this, I am getting an error saying that the value cannot be determined in this context. What am I doing wrong?
You are creating a measure that has a context of several rows rather than 1 row, so it can't determine the true/false test in your if statement. Try this DAX for your calculated measure:
MyMeasure:= Calculate(DistinctCount(Table[columnid]), Table[column a] = "True")
Here's a good article on the CALCULATE function in DAX: http://sqlblog.com/blogs/marco_russo/archive/2010/01/03/how-calculate-works-in-dax.aspx