SUMIF with date range for specific column - filter

I've been trying to find an answer for this, but haven't succeeded - I need to sum a column for a specified date range, as long as my rowname matches the reference sheet's column name.
i.e
Reference_Sheet
Date John Matt
07/01/19 1 2
07/02/19 1 2
07/03/19 2 1
07/04/19 1 1
07/05/19 3 3
07/06/19 1 2
07/07/19 1 1
07/08/19 5 9
07/09/19 9 2
Sheet1
A B
1 07/01
2 07/07
3 Week1
4 John 10
5 Matt 12
Have to work in google sheets, and I tried using SUMPRODUCT which told me I can't multiply texts and I tried SUMIFS which let me know I can't have different array arguments - failed efforts were similar to below,
=SUMIFS('Reference_Sheet'!B2:AO1000,'Reference_Sheet'!A1:AO1,"=A4",'Reference_Sheet'!A2:A1000,">=B1",'Reference_Sheet'!A2:A1000,"<=B2")
=SUMPRODUCT(('Reference_Sheet'!$A$2:$AO$1000)*('Reference_Sheet'!$A$2:$A$1000>=B$1)*('Reference_Sheet'!$A$2:$A$1000<=B$2)*('Reference_Sheet'!$A$1:$AO$1=$A4))

This might work:
=sumifs(indirect("Reference_Sheet!"&address(2,match(A4,Reference_Sheet!A$1:AO$1,0))&":"&address(100,match(A4,Reference_Sheet!A$1:AO$1,0))),Reference_Sheet!A$2:A$100,">="&B$1,Reference_Sheet!A$2:A$100,"<="&B$2)
But you'll need to specify how many rows down you need it to go. In my formula, it looks down till 100 rows.
To change the number of rows, you need to change the number in three places:
&address(100
Reference_Sheet!A$2:A$100," ... in two places
To briefly explain what is going on:
look for the person's name in row 1 using match
Use address and indirect to build the address of cells to add
and then sumIfs() based on dates.

alternative:
=SUMPRODUCT(QUERY(TRANSPOSE(QUERY($A:$D,
"where A >= date '"&TEXT(F$1, "yyyy-mm-dd")&"'
and A <= date '"&TEXT(F$2, "yyyy-mm-dd")&"'", 1)),
"where Col1 = '"&$E4&"'", 0))

Related

Elastisearch Query to filter out values in column based on another column

I'm working with a dataset that I'm trying to filter, but I'm having trouble trying to get the results I want, and I'm not sure it's possible to do so. Some sample data is below:
Column A
Column B
Column C
Column D
good
awe
1
9834
great
niopre
1
78964
bad
nue
1
12
good
btr
2
6543
great
muy
2
8765
bad
xdrg
2
1432
bad
thr
3
648
good
cfg
3
6
bad
mk
3
1958
What I want to do is use Column A and C in the filter and only show the values in Column C that also have a row that includes "great" in Column A. So for this dataset the filter would return:
Column A
Column B
Column C
Column D
good
awe
1
9834
great
niopre
1
78964
bad
nue
1
12
good
btr
2
6543
great
muy
2
8765
bad
xdrg
2
1432
I've tried through the built in filters and through the Elasticsearch Query DSL and haven't had any luck yet. If anyone can help guide me in the right direction on how to do this it would be greatly appreciated.

Group on sum of distinct values in Tableau

I'm using Tableau 8.3 and i'm trying to find out how to group on each of the values that I find after making a "count of distinct values".
To illustrate the case I have made a fictive dataset which includes 58 rows (buys), 7 different IDs (customers) and 5 different products. Then I have made a count distinct to find out how many of the 5 different products each ID have bought. It looks like this.
ID1 = 4
ID2 = 4
ID3 = 5
ID4 = 4
ID5 = 3
ID6 = 4
ID7 = 2
Now I want to turn the view around and find out how many of the IDs who have bought X different products. It should ultimately look like this.
2 = 1
3 = 1
4 = 4
5 = 1
Hope to find a solution by posting here! Thank you,
Mikael
You need to update to Tableau 9.0 to achieve that (in a fast way).
You can create a calculated field named #of products:
{ FIXED [id_customer] : COUNTD([id_product]) }
Then you can cross the [# of products] with COUNTD(id_customer) to get what you want.
In older versions of Tableau you need to create a new table in a proper format (1 line per customer with the aggregations) and connect to it.

XPages ratio between 2 column totals in view

I have a view with 2 columns. Both number types. I want to add a button to the page, which will calculate the ration between total of column 1 and total of column 2.
For example:
Column 1 | Column 2
5 | 5
10 | 10
4 | 3
3 | 4
It should be (5+10+4+3)/(5+10+3+4) = 1..
Thank you,
Florin
I would probably go into the view properties and turn on the totals for both those columns. Then in SSJS I'd get a NotesNavigator for that view and then create a NotesViewEntry object. Then I'd set that ViewEntry to the NotesNavigator.getLastEntry()... something like that. That entry should then have a columnValues() property. I THINK it would be something like:
var column1 = entry.getColumnValues()[1];
var column2 = entry.getColumnValues()[2];
Note: getColumnValues() is zero based and depending on the view design some columns might not be available to retrieve from getColumnValues().
Once you have you're 2 var's then you can do the math and do whatever with the result.
That's how I would approach it at least.
(I don't have an editor handy so sorry if some of the syntax is off)

Rdlc - calculate sum of columns and display total in a single cell conditionally

Here is the scenario, I have a dataset with fields Category, Country and NUM_SCHOOLS.
i created a column to populate the country names as columns. I created a row group to calculate the row column. In my current report Column headers(Country) Country1, Country2....so on are displayed and row headers(Category) A, B, C and D are displayed. Values is [Sum(Fields!NUM_SCHOOLS.Value)]. Everything is correctly displayed
I used pipe(|) symbol as the separator between the cells, i am not allowed to post images, i tried my best to explain. Please let me know if you need any information to help me.
Current Report:
Country1 Country2
A 10 | 12
B 5 | 6
C 5 | 7
D 11 | 15
Required report:
Country1 Country2
A 10 | 12
B 5 | 6
C 5 | 7
D 26
Only for D column, i want to add the numbers and display the value as a single value. (11+15=26), for other categories it should display in different country buckets.
Please help me out. Thanks in Advance!
Sum of more than One Columns Quantity of More than one dataset in rdlc.=Sum(Fields!QUANTITY.Value, "Tone")
+Sum(Fields!QUANTITY.Value, "Buffalo")
+Sum(Fields!QUANTITY.Value, "Cow")
Sorry to be the bearer of bad news, but I don't think that you can merge columns across column groups.
I think that the best option is to remove your column grouping and manually add in 7 columns for your receipt frequencies. You'd have to use a Sum with an Iif to get your values correctly, for instance in the far left column, something like:
=Sum(iif(fields!RECIEPT_FREQUENCY.Value="ANNUAL" ,Fields!val.Value,0))
then you could add a merged cell underneath and add the following expression
=Sum(iif(Fields!PART_COUNT.Value="D", Fields!val.Value,0),"DataSetName")
Alternatively, you could leave it as it is and enter the following expression in a total row at the bottom of your matrix. But you would have to do something expression based for the cell borders to give the illusion of it being merged..
=Sum(iif(Fields!PART_COUNT.Value="D"
And fields!RECIEPT_FREQUENCY.Value="BI-WEEKLY"
,Fields!val.Value,0),"DataSetName")

How to reference a specific Group Total of one dataset in the expression in different dataset

I have a report with multiple datasets. In one of them I need to reference the group total from another dataset. It looks like this:
Tablix1:
Region1 Total Age1 Age2
a 7 5 2
b 12 6 6
c 20 12 8
Total 39 23 16
Tablix2:
Region2 Value %
a 4 57.14%
b 6 50.00%
c 5 25.00%
The values in the "%" column of Tablix2 come from formula: %a = Tablix2 Value a / Tablix1 Total a.
My current expression in % column of Tablix2 looks like:
=CountDistinct(Fields!ID.Value, "Region2")/CountDistinct(Fields!CONSTITUENT_ID.Value, "Tablix1")
but what I get is the percentage calculated of the Total row of Tablix1 and not each Region of Tablix1.
The Lookup function would work for this. It's similar to a vlookup in Excel. It would look something like this:
=Lookup(Fields!Region1.Value, Fields!Region2.Value, Fields!ID.Value, "Region2")
This would pull the corresponding value from Region 2 into Tablix 1. You can just switch it around if you want it in the other table.

Resources