How to create a ranged frequency table using Excel Cube functions - excel

What I want is to create something like this (see image) in Excel that pulls in the frequency of my chosen category from a table within my PowerPivot data model. The output would also need to be dynamically filtered via a cell reference.
Using the below data set as an example:
Week 1 A
Week 1 A
Week 1 A
Week 1 A
Week 1 A
Week 1 B
Week 1 B
Week 1 C
Week 1 D
Week 2 A
Week 2 A
Week 2 A
Week 2 A
Week 2 A
Week 2 A
If I filtered to Week 1 through my set expression, the following output would be produced
1 2
2-4 1
5+ 1
However, if filtered to Week 2, this output would be produced
1 0
2-4 0
5+ 1
I say 'set expression' because I am assuming the way to do this is through the CUBESET function possibly with a MDX FILTER function and the CUBESETCOUNT functions though I am open to other suggestions. Even though the example doesn't show it, I need the expression to filter multiple dimensions from my cube, in particular, date, which is found in my calendar table.
I also understand that I could create specific measures within PowerPivot to handle this (sample formula below), but I would like to know if this is possible via the CUBESET function.
Freq (5+):=CALCULATE(
DISTINCTCOUNT([myColumn]),
FILTER(myTable,
COUNTROWS(FILTER('myTable', [myColumn] = EARLIER([myColumn]))) >=5 )
)
I am also open to creating a helper column within my Powerpivot table.
Thanks,

Related

EXCEL formula to sum demand per date when multiple entries of dates exist

How do I sum the amount of demand I have for each date, when there are multiple entries for each date., e.g.
Sheet 1:
A B
Date Demand
13/7/21 5
13/7/21 4
13/7/21 2
15/7/21 6
15/7/21 3
16/7/21 2
16/7/21 4
So I'm trying to get a summary as follows:
Sheet 2:
A B
13/7/21 11
14/7/21 0
15/7/21 9
16/7/21 6
17/7/21 0
I've tried =SUMPRODUCT(--('Sheet 1'!$A$2:$A$240='Sheet 2'!A2),'Sheet 1'!$B$1:$B$240)
I'm not wanting to do a pivot table, as the pivot table does not give me the zero values for dates where there is no data (unless there is a way to show this in a pivot)
You can use SUMIFS() like
=SUMIFS(Sheet1!B:B,Sheet1!A:A,A1)
You can also use SUMPRODUCT() in this way.
=SUMPRODUCT((Sheet1!$B$2:$B$8)*(Sheet1!$A$2:$A$8=A1))
Put together quickly to start you off:
Edit to give text version of the solution to the OP's problem:
=SUMIFS(B6:B12,A6:A12,"="&G12)
Then you can do between by setting lower and upper criteria in the sumifs().

Count of Excel based on 2 column criteria and counting the 3rd column

I need a count of how many date items fall within Data 1 & Data 2
ie:
x-1 will have a count of 2
x-2 will have a count of 1
-x-3 will have a count of 2
-y-1 will have a count of 2
What would be the best way to go abouts when approaching this?
Data 1
Data 2
Date
x
1
Date 1
x
1
Date 1
x
1
Date 2
x
2
Date 3
x
2
Date 3
y
1
Date 1
y
1
Date 1
I see only one way to interpret with the available information:
To count the number of times Date_to_test falls within Date_1 and Date_2 (screenshot below, sheet here), you could use either the sum or something like a countifs (with interim calc):
sum approach
=SUM(1*($C$2:$C$11<=$B$2:$B$11)*($A$2:$A$11<=$C$2:$C$11))
countifs + interim calc
helper
=1*(C2<=B2)*(A2<=C2)
(additional column, drag down)
countifs
=COUNTIFS($D$2:$D$11,1)
Screenshot
Alternative
as for the 'sum' approach, sumproduct variants (e.g. =SUMPRODUCT(1*($C$2:$C$11<=$B$2:$B$11),1*($B$2:$B$11>=$A$2:$A$11))) are calculation/memory intensive
despite the countifs + helper approach containing more 'visible' data - these values need only be calculated once, the countifs can then be determined independently (assuming no updates to the helper column) - thus making it more memory/calculation efficient depending upon your calculation mode, screen-updating preferences
Caveat
if, by some misfortune re: interpreting your question, you are referring to some other means of establishing whether "date items fall within Data 1 & Data 2", then without knowing what this is, there very low likelihood of being able to guess this correctly

Count specific column values by year in another date column in Excel

I have an excel table with two columns and several hundred rows. One column lists a single-digit code that represents an event, the other the date of that event. I'm attempting to count the number of times a particular event (say "1") occurred in a particular year (say 2017).
I normally use "COUNTIFS" for two or more criteria, but I'm stumped by the date format. I can't seem to get it to work in the formula. In this case, I'm using the yyyy-mm-dd format. How can I perform this operation?
A small example of the table is as follows:
------------------------
A B
--+--------------------+
1 Event Date
2 1 2016-09-12
3 1 2019-10-11
4 3 2017-03-24
5 2 2016-05-25
6 3 2017-08-02
7 1 2018-10-11
Just use
=COUNTIFS(A:A,1,B:B,">="&DATE(2017,1,1),B:B,"<="&DATE(2017,12,31))
EDIT:
if you have text-that-looks-like-dates, you can use SUMPRODUCT and YEAR:
=SUMPRODUCT((A2:A7=1)*(YEAR(B2:B7)=2017))

Excel sumifs until a new value in column

I have some data that looks like:
Day Result
1-Nov 1
0
1
2-Nov 1
3-Nov 0
0
4-Nov 1
There are other columns with data. I only have the date once as the data is displayed graphically in a time series.
Now I'd like to setup a summary table that aggregates each day. I cannot use sumifs because the date is only in the data once.
How could I write a calculation such that excel sees a2 has a value so sums b2,b3,...bi until ai has a value.
Preferably not vba, never learned it and want to do this in excel rather than R or Python.
EDIT:
I am specifically looking at how to do calculations on the result column grouped by each date. Blank cells should be considered the same date. So when excel sees 1-Nov it then does a calculation (i've said sum but any we can extend to) on 1,0,1 and then stops and a new calculation is done for Nov-2.
IMHO, instead of using a table like this:
Day Result
01/nov 1
0
1
02/nov 1
03/nov 0
0
04/nov 1
You should populate the "Day" column and use a pivot table to summarize the results.
I.e.:
Day Result
01/nov 1
01/nov 0
01/nov 1
02/nov 1
03/nov 0
03/nov 0
04/nov 1
And the pivot table:

Count in Excel over a range using 2 columns of data

Tried looking for an answer first...
I want to count the number of items that were open between 1-7 days, 8-14 days, etc etc (open and closed on same day = open for 1 day)
Is there a way I can count this directly using the 2 columns holding the data without creating a 3rd column for Date Closed - Date Opened +1??
So in this example, what can I use to calculate that the number of 1-7 days items is 2? (Items 1 and 3)
Item # Open Closed
1 01/06/2014 01/06/2014
2 05/05/2014 20/06/2014
3 10/06/2014 16/06/2014
4 08/06/2014 15/06/2014
5 02/06/2014 19/06/2014
Many thanks :o)
One way would be to use the versatile SUMPRODUCT:
=SUMPRODUCT(1*(C2:C6-B2:B6+1>7))
assuming your start date column is B and end date column is C. The second part of the formula will determine all date spans which are larger than 7, and the 1* will convert the TRUE values to 1 in order to sum them up.

Resources