How to count Product ‘A-D’ without Null Value? - qlikview

When I was trying to create a dashboard in Qlikview, I write a statement to show up the following product data in a bar chat:
As you can see in the pic, however, the is a null value product to be counted.
I write the following statement in the Expression of Qlikview BarChart:
Count({<PRODUCT={'Enoxaparin Sodium','Insulin Glargine 300','Non-Promotional','Sevelamer Carbonate'}>}DISTINCT CALLID).
It can display what I want to see, but some other product may be missing in the future counting.
Who can tell me how to write an expression to count all the product without couting Null Value in Product Field?
I input like this Count({<PRODUCT={'<>NULL'}>}DISTINCT CALLID), but it didn't work.

I have resolved this problem by doing this:
count(distinct if(Not IsNull(PRODUCT),CallId))

Related

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

SQL custom grouping expression based on the field value string Microsoft Visual Studio

I am having a table in BIDS with three columns (e.g. Team, Product Name, Count).
For the Column Product name, I want to apply grouping, that will check for particular string "laptop" and sum all the Product Names containing string "laptop" under Laptops. Values in Product Name may vary, but there is a certain pattern like XX.Laptop.1, YY.Laptop.2 and mix of combinations to laptop.
I need something that will render full list, but add a group over Tablix Group with use of custom expression =IIF(Fields!Product_Name.Value)LIKE "laptop", "Laptops")
Please kindly advice. Thank you
Much thanks Alejandro! here is the result I got after applying your suggestion.
RESULT
I need two additional questions:
If there is a second group I would like to use for grouping - how to add it? (eg. desktops)
How to add a sumary value for the group? Shall it be done over exprerssion?
Thank you
Try using this expression for setting the group by Product Name and to show the Product Name in the respective cell.
=IIF(InStr(Fields!Product_Name.Value,"laptop") > 0,"Laptops",Fields!Product_Name.Value)
If for a specific row the Product Name contains laptop it will group on "Laptops" otherwise it will group by the Product Name value for that row.
UPDATE: If you want to check for another word to create an additional group you can use:
=Switch(
InStr(Fields!Product_Name.Value,"laptop") > 0,"Laptop",
InStr(Fields!Product_Name.Value,"desktop") > 0,"Desktop",
true,Fields!Product_Name.Value
)
Let me know if this helps.

SSRS Divide Sums from Different Scopes Returns 0

I have a grouped dataset. From the parent group down, the group names are:
Company > Plant > Details. In the end, I want to be able to take the sales of each plant and see what percentage it is of the entire company's sales. Let's say the company has a total sales of $500 and the sales of "Plant A" were $100 and "Plant B" sales were $400. I would image that I would need an expression at the Plant grouping level that was like:
=Sum(Sales)/Sum(Sales, "Company")
And I would get .2 for Plant A and .8 for Plant B. But if I do that, I get 0. I am at a complete loss. Any help with this would be greatly appreciated.
Additional information:
My exact setup is a little more complex than the example I gave below, but I believe the general idea still holds the same. I have a total of 6 groups:
The circled group is the equivalent of the "Plant" Group in my example. Here is the row group in my tablix for the GroupBy group (the one with the arrow pointing to it).
The expression that is circled in the picture above is the expression in question to get my percentage (right now really just a decimal, not formatted to be a percentage yet).
=sum(Fields!ActualCurrent.Value)/sum(Fields!ActualCurrent.Value, "Company")
Fields!ActualCurrent.Value is the equivalent of "Sales" in my example above. The expression above returns 0 for all groups. But yet, if I change it to
=sum(Fields!ActualCurrent.Value)+sum(Fields!ActualCurrent.Value, "Company")
It will produce the equivalent of $600 for "Plant A" and $900 for "Plant B."
I can't seem to find how it reacts as expected when adding the two sums, but produces 0 when I divide them.
It would be useful to see where are you using that expression to determine what is wrong here, but I think you can use this guide to get your desired result.
Create a tablix like this:
Note I've added Company and Plant fields as groups. Also I've deleted details group. Right click details and select Delete group and set Delete group only option.
Now in the percentage column use the following expression:
=FORMAT(
SUM(Fields!Sales.Value,"Plant")/SUM(Fields!Sales.Value,"Company")
,"P2"
)
The sum of every plan divided by the sum of the whole company group. It is not necessary but I am using FORMAT function to format the float value returned by the expression to percentage format using two decimal places.
It should show something like this:
UPDATE: Try scoping the sum to your specific group: GroupBy
=sum(Fields!ActualCurrent.Value, "GroupBy")/sum(Fields!ActualCurrent.Value, "Company")
UPDATE 2: Format the cell to show decimal digits.
Use thiss expression:
=FORMAT(
sum(Fields!ActualCurrent.Value, "GroupBy")/sum(Fields!ActualCurrent.Value, "Company"),
"F2"
)
It will format the value returned by the expression as a float with two decimal digits.
If you want to show the value in percentage format replace F2 in the expression for P2 (Percentage format with two decimal digits.)
Let me know if this helps.

Percent of Group, not total

It seems like there are a lot of answers out there but I can't seem to relate it to my specific issue. I want to get the breakdown of yes/no for the specific Group. Not get the percent of the yes for the entire population of data.
I have tried the following code in the "What I'm Getting" % of Total cell =
=FormatPercent(Count(Fields!SessionID.Value)/Count((Fields!SessionID.Value), "Tablix1"),)
=FormatPercent(Count(Fields!Value.Value)/Count((Fields!SessionID.Value), "Value"),)
It should just be a case of changing the Scope in your expression to make sure the denominator is the total for the group, not the entire Dataset or Tablix, i.e. something like:
=Count(Fields!SessionID.Value) / Count(Fields!SessionID.Value, "MyGroup")
Where MyGroup is the name of the group, i.e. something like:
If this is still not clear, your best option would be to add a few sample rows, and your desired result for these, to the question so we can replicate your exact issue.
Edit after more info added
Thanks for adding more details. I have created a Dataset based on your example:
And I've created a table based on this:
The group is based on the Group field:
The Group % expression is:
=Fields!YesNoCount.Value / Sum(Fields!YesNoCount.Value, "MyGroup")
This is taking the YesNoCount value of each row and comparing it to the total YesNoCount value in that particular group (i.e. the MyGroup scope).
Note that I'm using Sum here, not Count as in your example expression - that seems to be the appropriate aggregate for your data and the required value.
Results look OK to me:

How to Calculate specific cell total in SSRS?

As shown below image i have problem to calculated specific fields total.
I want to just calculate only two cells value like
total=(total opening-qty) + (total purchase-qty) cell and opening, purchase, sales are all from Type Group.
Please tell me the Expression or tips.
It's hard to tell without seeing your DataSet/report, but the expression would be similar to:
=Sum(IIf(Fields!Type.Value = "OPENING" or Fields!Type.Value = "PURCHASE"
, Fields!qty.Value
, Nothing)
This will take a SUM of all qty values, but it will ignore any Type rows that don't match the types you're specifying, i.e. OPENING and PURCHASE.
The most import thing is to make sure the expression is in the correct Scope, i.e. if you're grouping by Type the expression should be applied outside of that group Scope to make sure the expression is considering all the required rows.