Summarising data

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
3,780
Ctrl+T changimg range to Excel Table that's all
PowerQuery changing source range to Excel table then load source into PQ editor where you can transform data as you wish, eg. filter column Year by 0, then load result back to the sheet

sourceresult PQ
ProjectItemYear 1ProjectItemYear 1
A
1.1​
500​
A
1.1​
500​
B
1.1​
0​
C
1.2​
200​
C
1.2​
200​
B
1.3​
400​
B
1.3​
400​
C
1.1​
100​
B
1.1​
0​
A
1.4​
700​
C
1.1​
100​
A
1.4​
700​
A
1.2​
0​
Code:
[SIZE=1]
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", type text}, {"Item", type number}, {"Year 1", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Year 1] <> 0))
in
    #"Filtered Rows"[/SIZE]
 
Last edited:

hatstand

Well-known Member
Joined
Mar 17, 2005
Messages
729
Hi,

I wasn't sure if you had got what you needed, but I'll post my effort in case it helps.

1) Paste the function below into a module. Thank you Chip Pearson.
2) Create two columns before you data.
3) In column 1 enter =IF(E7=0,"",C7&D7&E7). This will create a list of all the values concatenated together.
4) In column 2 highlight the range as long as your data and enter =noblanks(A7:A14). Then press SHIFT + CTRL + ENTER, this will create a list without blanks.
5) In column G (on the same line as the first line of data), enter =IF($B7="","",VLOOKUP($B7,$A$7:$E$14,3,FALSE)) and copy down as long as your range. You can then use the same formula for the columns 2 & 3.

A very messy approach but it works.

Function NoBlanks(RR As Range) As Variant
Dim Arr() As Variant
Dim R As Range
Dim N As Long
Dim L As Long
If RR.Rows.Count > 1 And RR.Columns.Count > 1 Then
NoBlanks = CVErr(xlErrRef)
Exit Function
End If

If Application.Caller.Cells.Count > RR.Cells.Count Then
N = Application.Caller.Cells.Count
Else
N = RR.Cells.Count
End If

ReDim Arr(1 To N)
N = 0
For Each R In RR.Cells
If Len(R.Value) > 0 Then
N = N + 1
Arr(N) = R.Value
End If
Next R
For L = N + 1 To UBound(Arr)
Arr(L) = vbNullString
Next L
ReDim Preserve Arr(1 To L)
If Application.Caller.Rows.Count > 1 Then
NoBlanks = Application.Transpose(Arr)
Else
NoBlanks = Arr
End If
End Function
 

EvansB2

Board Regular
Joined
Nov 25, 2008
Messages
210
I'm still contemplating this one and so thanks for the response. I will certainly give it a go.
 

Forum statistics

Threads
1,081,834
Messages
5,361,594
Members
400,639
Latest member
fleyd

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top