Is there any good implementation of a directive that dynamically change heights of element to fill remaining container's height?
In my layout I've header (actually menu) fixed height in pixels, content area (that could overflow above window height so scroll bars should appear) and sticky footer with fixed height. Also on a left and right of content area there could be panels
So something like that:
┌──────────────────┐
│ Header │ ~100px
├─┬──────────────┬─┤
│P│ ▲│P│
│a│ Content ▒│a│ fill remaining area, with scroll bars
│n│ ◙│n│
│e│ ▒│e│
│l│ ▼│l│
├─┴──────────────┴─┤
│ Footer │ ~100px
└──────────────────┘
I've tried such solutions:
Using height: 100%. But as header/footer are in pixels, so its hard to measure their height in percents, this solution din't solved problem.
Using haks like "display: table-row" didn't allowed to have scroll bars for content area
As it is quite common layout for web sites, there are quite a lot of solutions using JS, but mostly all of them were not generic - or without possibility to have scroll bars, or panels would not be possible.
So I as understand, the only solution is to use JavaScript for adjust height of en element, so the best place where to put is directive.
Do anybody have some implementation of directive for this task?
Currently I've this solution:
http://plnkr.co/edit/Nimw68KXJRCU3RZzu3Bc?p=preview
Directive fill work this way::
Calculate padding-bottom + margin-bottom + border-bottom-width of all elements, that contains current element
Add heights of all elements beneath the current element and beneath all elements, containing current element
Subtract from window height offsetTop of the element and result of previous calculations
Set element's height to resulting value
So the idea of height calculation (actually height of area beneath of current element) is:
╔══════════════════════════╗
║ ║
║ ╔═════════════╗ ║
║ ║ Element ║ ║
║ ║ to autofill ║ ║
║ ............... ║
║ ╚═════════════╨───────╫─────────
║ ║ + margin/padding
║ ╔════════════════════╥──╫─────────
║ ║ some element ║ ║
║ ║ below ║ ║ + height
║ ║ ║ ║
║ ╚════════════════════╨──╫─────────
║ ║ + margin/padding
╚══════════════════════════╨─────────
There are some restriction:
I assume that widths of paddings, margins, borders are specified in pixels (convert from other units seems to be quite complex)
I didn't tested it on other browsers except Chrome.
Improvements are welcome!
Related
I am not sure if the title makes sense, but you can have a look at the example below. Considering I have a 2-column table in Excel like this:
Fruit | Amount
Apple | 2
Grape | 4
Orange | 3
Now I want to have this row:
Apple | Apple | Grape | Grape | Grape | Grape | Orange | Orange | Orange
that when I change the number from "Amount" column in the table, the row changes accordingly as well. For example, if I now have 5 Grapes, it would become:
Apple | Apple | Grape | Grape | Grape | Grape | Grape | Orange | Orange | Orange
Is it possible to do in Excel? I am fairly new with this. Thanks!
This can be achieved with a combination of
REPT - to generate the repated copies of the words
CONCAT - to join those repitions together
FILTERXML - to split the list into cells
TRANSPOSE - to return a row rather than a column
=TRANSPOSE(FILTERXML("<a>"&CONCAT("<b>"&REPT(B5:B7&"</b><b>",C5:C7-1)&B5:B7&"</b>")&"</a>","//b"))
Currently in BETA, but if available through insider's plan, try to use SCAN():
Formula in D1:
=XLOOKUP(SEQUENCE(1,SUM(B2:B4)),SCAN(0,B2:B4,LAMBDA(a,b,a+b)),A2:A4,,1)
Let me try and explain the steps:
The SCAN() functionality can be used to create a running total. A starting value of 0 will continue to grow through recursive LAMBDA() functionality. In the current example this will return {2,6,9}.
Now the idea is to find approximate matches using XLOOKUP(). The input for this function is an array created through SEQUENCE() where the amount of columns will equal the SUM() of all amounts. Thus; {1,2,3,4,5,6,7,8,9} in this case. Using the 5th parameter we can return the position of the exact or nearest higher value in the lookup array we found using SCAN(). The result: {1,1,2,2,2,2,3,3,3}.
The next and last step is also done in XLOOKUP() where we used A2:A4 inside the 2nd parameter to return elements from the previous found numeric indices. Obviously the result will then be {"Apple","Apple","Grape","Grape","Grape","Grape","Orange","Orange","Orange"} .
I tried to visualize the above in a process that may help a little.
And as your amount change, so does the output as required:
Here is a simple function to do a text multiple. You can then stack up the results.
Function TextMultiplier(MyText As String, MyMultiple As Integer)
Dim Output As String
For a = 1 To MyMultiple
Output = Output + MyText + " "
Next a
TextMultiplier = Trim(Output)
End Function
Here is how it looks:
I have this excel table
Status | Priority |
-------------------
Yes | High |
No | Medium |
N/A | Medium |
Yes | Low |
A bit | Bonus |
| |
| |
Each priority has a point value. Priority points can change to anything. They aren't in order. Note that lines can also be blank. Assuming that if priority is blank then status is also blank.
High = 3 points
Medium = 2 Points
Low = 1 Point
Bonus = 1 Point
Status's can be blank or any value. However if they are the following then they have coniditions:
Yes = Full point (eg. Yes with High priority gives 3 points) or (eg. Yes with Bonus gives 1 point).
A bit = Half a point (eg. A little with High priortiy gives half 1.5 points) or (eg. A little with Medium gives 1 point). Essentially halving the point.
If the Status is Yes then I want it to count the corresponding point value. So for the table above it should count up 4.5 points.
3 Points for Row 2
1 Point for Row 5
0.5 points for Row 6
I was wondering how I can do this?
I was going to do the following, but it only has one condition.
=COUNTIF(A2:A5, "Yes")
Using Tables and Named Ranges with structured references gives you a great deal of flexibility.
I first set up two tables
priorityTbl
statusTbl
With our Input, I Named the two Ranges Status and Priority
The total is then given by the formula:
=SUMPRODUCT(IFERROR(INDEX(statusTbl,MATCH(Status,statusTbl[Status],0),2),0),
IFERROR(INDEX(priorityTbl,MATCH(Priority,priorityTbl[Priority],0),2),0))
If you want to change the values you assign to the different Priority/Status items, you merely change them in the table.
You could also add new rows to the tables, if that is appropriate.
Note that I did not bother adding to the tables rows where the value might be zero, but you could if you wanted to.
I have a spreadsheet with a list of T-shirts and all of their varying sizes from Small to XL. I was just wondering if there is a way to create a formula that will set the price of the shirt in another row. I was messing around with formulas and the only one I could get to sort of work (for only ONE t-shirt size) was the following:
=IF(COUNTIF(K:K,"S"),25)
Is there a way to have multiple statements for the different sizes? Thanks in advance!
I would create a
"reference table" in a separate sheet and then do a vlookup.
So the table would look like below and then just do a vlookup to where all your shirts are at.
Size | Price
XS | 5
S | 10
M | 15
L | 20
XL | 5
This question already has answers here:
How many times does each value appear in a column?
(3 answers)
Closed 6 years ago.
I have an excel table which contains information about bugs containing columns such as Product, Owner, etc.
The Product column contains values (strings) such as PTS, SDE, etc.
How do I find the count of occurrences of each of product (PTS or SDE)?
For example, the following table -
╔════╦══════════════╦═════════╗
║ id ║ Product ║ Owner║
╠════╬══════════════╬═════════╣
║ 1 ║ PTS ║ thiru║
║ 2 ║ PTS ║ sajeesh║
║ 3 ║ SDE ║ varun║
║ 4 ║ SPB ║ ranjith║
╚════╩══════════════╩═════════╝
when queried for Product column would return
PTS - 2
SDE - 1
SPB - 1
The easiest solutions are PivotTable, Power Query, PowerPivot, etc.
Unlike the formula solutions, they do not auto-update when the source range is changed, but you can configure how often they are refreshed or refresh them manually.
Product Formula Result
PTS =countif(Product_Range, "PTS") 2
SDE =countif(Product_Range, "SDE") 1
SPB =countif(Product_Range, "SPB") 1
The countif formula is looking through the data range with product names, and counting the number of items that matches the name you specified in the formula.
Here are the arguments that countif takes
=countif(range, criteria)
I have a list of items sold which grows longer with each sale. On a summary page I want to sum particular rows of a column.
Example:
Sheet1
Person Item Amount
1 5 6.00 This page has the knows the last column
1 7 10.50 by =counta($a2:$a20)+1 in cell f6
2 5 6.00
3 2 20.00
3 9 16.00
3 5 6.00
4 1 2.50
Summary Page:
Person Sales
1 =sumif(sales!$A$2:$A$8,$a2,sales!$C$1:$C$8) = 16.50
2 =sumif(sales!$A$2:$A$8,$a3,sales!$C$1:$C$8) = 6.00
3 =sumif(sales!$A$2:$A$8,$a4,sales!$C$1:$C$8) = 42.00
4 =sumif(sales!$A$2:$A$8,$a5,sales!$C$1:$C$8) = 2.50
On one page I create an indirect reference by =concatenate("sales!$c$2:$c$",sales!$a$10) but that won't work on this one page. Is there another way?
Please try:
=SUMIF(sales!A:A,A2,sales!C:C)
copied down to suit.
I would use dynamic named ranges:
=SUMIF(Sales!People,A2,Sales!Amounts)
Here is an article on how to create dynamic named ranges:
http://www.excel-easy.com/examples/dynamic-named-range.html
If this is really a "Table", in other words, you used the Insert Table method from the Insert Ribbon to set it up, then you can merely used structured references which will automatically expand as you add rows.
An equivalent of your formula, using structured references, and assuming you have renamed your table SalesTbl, might look like:
=SUMIF(SalesTbl[Person],$A2,SalesTbl[Amount])