In Power Query Editor, I have a table I want to filter on a specific column. When I click on the arrow on the column header, it first gives me following items:
When I click "Load More", the first entry "100R1" is not available anymore? I also know there should be other values (like "500", but those are also not shown)...
This behaviour starts only after I do a NestedJoin like so:
= Table.NestedJoin(Source,{"Number"},Parts,{"Parts"},"Parts",JoinKind.Inner)
So, the column that I join on is Number, the column I want to filter on is Type ...
When I try to filter Type on the Source table, it behavious correctly...
How is this possible?
PS: If I adjust the filter manually from:
Table.SelectRows(JoinedTable, each ([Type] = "100R2" or [Type] = "400R1" or [Type] = "400R2"))
to
Table.SelectRows(JoinedTable, each ([Type] = "100R2" or [Type] = "400R1" or [Type] = "400R2" or [Type] = "100R1"))
it effectively keeps instances of "100R1" ...
Once I've faced situation, when filters in PQ are lied to me. The problem was solved by clearing cash.
Related
I am using this as a reference -- how concatenate multiple rows in LINQ with two tables?
I have the exact same needs, except that not all "printers" have "resolutions". In my particular case, I have a Lead table, which stores some basic information. Then there is a tag table, which stores tags used for the Lead. Not every lead has a tag.
This is what I have so far based on the above reference:
var leads = _dbRO.Leads.Join(_dbRO.Tags, p => p.LeadId, r => r.EntityId, (p, r) => new
{
LeadId = p.LeadId,
GigDate = p.GigDate,
Location = p.Location,
Tags = String.Join("|", _dbRO.Tags.Where(k => k.EntityId == p.LeadId)
.Select(lm => lm.TagName.ToString()))
}).Distinct();
This works well for me. However, leads without tags are NOT returned. How do I ensure all leads are returned regardless of tags. An empty string or null for Tags field would be fine.
Also if you don't mind, if I want to return the Tags in an object array, how do I do that? The reason is because there could be additional information associated with each tag, like color etc. So a simple concatenated string might not be sufficient.
Thanks a bunch!
I've figured out -- I do not need to join the tag table at all. This causes the problem. I just need to select from my Lead table and in the Select section, get the tags as I was already doing.
If you’ve declared a relationship between Lead and Tag entity types, then EF already supplies your requirements through the Include() extension method.
ctx.Leads.Include(l => l.Tags).ToList()
This requires that Lead declares a navigation property to Tag as shown below.
class Lead
{ ... public List<Tag> Tags { get; set; } }
I'm trying to merge the results of a prepared statement to TBS. Here's my code:
$s = $link->prepare("SELECT * FROM newsletters WHERE newsletter_id = :newsletter_id");
$s->bindParam(":newsletter_id",$newsletter_id);
$s->execute();
$newsletter = $s->fetch(PDO::FETCH_ASSOC);
$tbs->MergeBlock('$newsletter ', $newsletter );
But I can't get the results fields. I get errors like the following:
TinyButStrong Error in field [newsletter.title...]: item 'title' is not an existing key in the array.
I can't find my error.
MergeBlock() is for merging a recordset , so you should use $s->fetchAll() instead of $s->fetch(). The section of the template will be repeated for each record.
But if you have to merge a standalone record, use MergeField() instead of MergeBlock(). The single fields will be merged one by one without repeating.
I have two tables in the analysis. I am using the script below to be able to filter table A and pass those filter selections to the matching filter in table B. Table A and B are visualized in a bar chart. I am triggering the code when the value of a document property changes, following instructions here.
I am running into two problems.
1) After the script runs, clicking Reset All Filters results in only table A being displayed in the visualization. Clicking Reset All Filters again fixes the issue.
2)When I add a second filter (commented out in the code below), making a selection in the Type_A or or Type_B filter wipes out the type B data from the visualization. I think the problem is in how IncludeAllValues is being handled, but I don't know how to fix it. Any help will be appreciated.
from Spotfire.Dxp.Application.Filters import *
from Spotfire.Dxp.Application.Visuals import VisualContent
from System import Guid
#Get the active page and filterPanel
page = Application.Document.ActivePageReference
filterPanel = page.FilterPanel
theFilterA = filterPanel.TableGroups[0].GetFilter("Type_A")
lbFilterA = theFilterA.FilterReference.As[ListBoxFilter]()
theFilter2A = filterPanel.TableGroups[1].GetFilter("Type_A")
lb2FilterA = theFilter2A.FilterReference.As[ListBoxFilter]()
lb2FilterA.IncludeAllValues = False
lb2FilterA.SetSelection(lbFilterA.SelectedValues)
#########################Type_B###########################
# theFilterB = filterPanel.TableGroups[0].GetFilter("Type_B")
# lbFilterB = theFilterB.FilterReference.As[ListBoxFilter]()
# theFilter2B = filterPanel.TableGroups[1].GetFilter("Type_B")
# lb2FilterB = theFilter2B.FilterReference.As[ListBoxFilter]()
# lb2FilterB.IncludeAllValues = False
# lb2FilterB.SetSelection(lbFilterB.SelectedValues)
I need to add range filter for year. I redefine the Magento class in my module FullText\Collection. I also made changes in search_request.xml file. I found the code and it works for me:
$skus = [
'CNS334',
'U012840'
];
$this->filterBuilder->setField('sku');
$this->filterBuilder->setValue($skus);
$this->filterBuilder->setConditionType('in');
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
But I have data in the another tables. I try to join, but I cant get any results for my filtering.
$this->getSelect()->join(
[
'my' => 'make_year',
],
'e.entity_id = my.product_id'
$this->searchCriteriaBuilder->addFilter($this->filterBuilder
->setField('year')
->setValue(2014)
->setConditionType('from')
->create());
$this->searchCriteriaBuilder->addFilter($this->filterBuilder
->setField('year')
->setValue(2015)
->setConditionType('to')
->create());
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
To join your query with other tables you need criteria mapper.
As an example please look at \Magento\CatalogInventory\Model\ResourceModel\Stock\Item\StockItemCriteria::setStockStatus() - here is initiated the filter.
Setting new item in data array triggers mapper method \Magento\CatalogInventory\Model\ResourceModel\Stock\Item\StockItemCriteriaMapper::mapStockStatus().
This mapper contains \Magento\Framework\DB\Select with which we are able to work like in old-style collection.
The name of mapper method correlates with criteria's data array index. So if you add $this->data['custom_field'] the mapper function should be mapCustomField().
Please also note that if there is specific mapper function for the field the mapper will try to filter by mapped fields.
Actually I want to get the full table but it should be based on Doc_Type==distinct
Means it should only pick the records from table that has unique Doc_Type. I have tried with following but it returns me a single column into tolist() but I want to get full table. How can I do it?
var data = DB.tblDocumentTypes.Select(m => m.Doc_Type).Distinct().ToList();
You can use GroupBy
var data = DB.tblDocumentTypes.GroupBy(m => m.Doc_Type).Select(x => x.First());