saulpw / visidata

A terminal spreadsheet multitool for discovering and arranging data
http://visidata.org
GNU General Public License v3.0
7.8k stars 276 forks source link

[wishlist] use aggregators in column expressions #391

Closed aborruso closed 4 years ago

aborruso commented 4 years ago

Hi, a classic task working with tables is to write formula that uses the sum of a field, as parameter for another field calculation (Cell Value/SUM(FieldName)*100).

I know that vd is not a spreadsheet (it's better :) ), but I think that this is a really common task and it would be great to be able to write also whole field based expressions.

Thank you

pigreco commented 4 years ago

This functionality would be very useful, thanks @aborruso

anjakefala commented 4 years ago

Hi @aborruso!

Just clarifying the ask, you are interested in being able to use calculations run on an entire column in expr-col

E.g. =Total / SUM(Total) would set a cell in row A to the Total value in the row A divided by the SUM() of the entire Total column?

aborruso commented 4 years ago

@anjakefala yes, to be able to click = and write something like SUM(FieldA)/FieldB. From

FieldA FieldB
5      0.2
6      0.7
1      0.9
18     0.3
5      0.25

to

FieldA FieldB Result
5      0.2    175
6      0.7    50
1      0.9    38.8888888888889
18     0.3    116.666666666667
5      0.25   140

The first cell of Result is (5+6+1+18+5)/0.2

Thank you

saulpw commented 4 years ago

Kondo'ed for now.

aborruso commented 4 years ago

Kondo'ed for now.

What's the meaning of Kondo'ed ? (my english is not so good)

anjakefala commented 4 years ago

@aborruso :D

Marie Kondo is a lady from Japan who professionally helps people clean and organise their homes. She wrote some books on her practice. The first step she covers is a decluttering one. XD

Find what sparks joy, @aborruso!!