Doctrine 2 having statement and relationship - doctrine-orm

Im trying to build a query to get all products with available colors:
$qb->select('p', 'pcl')
->from('Entity\Product', 'p')
->leftJoin('p.availableColors', 'pcl', 'WITH'));
Also I want to get only products having only one specific color:
$qb->having($qb->expr()->eq('pcl.id', '1'));
but in response i got only one color (id = 1) instead of a full array. How I can build this query to get all colors appended to products? AvailableColors is ManyToMany relationship to other Entity.

Related

Displaying image in an Interactive Report

I am using APEX 21.1. I am building a clinic management system. I have an interactive report based on a join between two tables SELECT e.id examination_id,E.DIAGNOSIS,dbms_lob.getlength(a.img) img, a.id,attachment_id FROM examination e JOIN examination_attachment a ON A.EXAMINATION_ID = e.id. The examination could have many attachments. This is the result of the query.
I changed IMG column's type to Display Image. When it asks for BLOB ATTRIBUTES, I set table name to examination_attachment. That's the table that have the images. And I enter the primary key as the table's PK(id). The page displays error No data found. The SQL query returns that id duplicated when there is more than one row in the examination_attachment table. I think that's the reason behind the error but not sure. I created a view with the same select statement without the dbms_lob.... part. Just selected the IMG column. And in BLOB attributes, I set the table to the view name, and the primary key as the attachment_id because it's the column that's not duplicated. And it worked. But I need to get it to work without views and I need to know if the cause of the error is right?

How to filter cards based on table data row selection in Power BI?

I am working on a report that deals in employee feedbacks. I have different cards on top to show -
(Requests Received,Type of requests(social/others/security),Requests reported/not reported and expired).
All these cards have data based on a measure - Count of Employee IDs = count('vw_EmployeeFeedback'[Employee_Id]) + 0 and respective filter fields dragged on to them to show category type etc.
Below them I have a table to show the detailed view of the data. Such as names of manager raising the request, Request raised for(name field) , status of requests, submitted date etc. coming from the same view as Count of Employee Ids.
I want the cards to filter based on the selection of a row in the table.
The edit interaction are set to filter the cards, but all go zero or blank when I select a row in the table.
Please let me know how I can achieve this. Thank You!
I am assuming that you have different tables for your data source/s that is why it is not filtering when clicking the table entry. Try establishing the relationships of your tables. Just go to Models and then Manage Relationships. If it's not the case, then you need other solutions.

Display Matched and Non Matched Values based on a slicer value Power BI

I am working on a Viewership table which tells which customer watches which asset. Based on the asset filter, I need to display the customers who watched the show & customers who didn't watched the show. below is my example table
If the asset_id selected as 1 in the slicer, the desired output will be as below
I have tried creating a cross-join table with asset_id and customer_id , but that approach taking much time with large data. Request the experts here to suggest the best optimal solution to achieve this.
First, create a new table "Asset":
This table contains unique assets, and we will use it to create a slicer that affects DAX measure but does not affect the visual (table). To achieve that, the Asset table must be disconnected from the Viewership table (no relationships).
In your viewership table, I just renamed "asset" to "asset_id", to be consistent:
Next, create a measure:
Status =
VAR Selected_Asset = SELECTEDVALUE(Asset[asset_id])
VAR Customer_Asset = SELECTEDVALUE(Viewership[asset_id])
RETURN
IF(Customer_Asset = Selected_Asset, "Watched", "Not Watched")
Result:
Slicer here is created from the "Asset" table, and table is a table visual with customer_id and asset_id from the Viewership table (set them as "don't summarize" values). I turned off "total", assuming you don't need it.
This design requires to set Asset slicer to "single selection" mode, to make sure that you are only getting one value from it. If you want the model to work with multi-select slicer, change DAX measure as follows:
Multi Status =
VAR Selected_Assets = ALLSELECTED(Asset[asset_id])
VAR Customer_Asset = SELECTEDVALUE(Viewership[asset_id])
RETURN
IF(Customer_Asset IN Selected_Assets, "Watched", "Not Watched")
Result:
Edit:
To make it work at the customer level:
Customer Status =
VAR Selected_Assets = ALLSELECTED(Asset[asset_id])
VAR Customer_Assets = VALUES(Viewership[asset_id])
VAR Assets_Watched = COUNTROWS(INTERSECT(Customer_Assets, Selected_Assets))
RETURN
IF(Assets_Watched > 0, "Watched", "Not Watched")
Result:
Explanation: store selected assets in a table variable. Then, store assets visible per customer in another table variable. Find an intersect of the two tables (what they have in common), and count intersect rows. If none - not watched, otherwise watched. If you want, you can actually display the number of movies watched (just return "Assets_Watched" instead of IF statement).

Generate multiple or single cell values based on conditions?

Problem:
I have single products and bundled products. I have a single "product ID" column and I want the sheet to recognize both bundled products and single products and, where it is a bundle, to fill the product ID for that bundle.
Here is the layout:
I have a list of bundles and the relevant product information on a separate sheet.
Explanation:
In column A, I enter either the product name of the Bundle ID.
Problem:
Is it possible for column B to detect whether Column A refers to a Bundle or single product? It detects a bundle, then can it generate the items in for bundle?
For example in A4= " - BUNDLE001" so in column B will generate the relevant product ID: B4= "LG001", B5= "PAN002". But I also need column B to know if it did not Bundle and to display the relevant product ID.
Sheet Link: https://docs.google.com/spreadsheets/d/1wPNYKbtbkaZ2LDrFq2RO_f13cfQeGcWsyhwS5VDkuvk/edit?usp=sharing
if your A column will look like this:
then you can use this formula on every row you need:
=ARRAYFORMULA(IFERROR(IFERROR(QUERY(Sheet2!A:C, "select C where A = '"&
REGEXEXTRACT(INDIRECT("A"&ROW()), TEXTJOIN("|", 1, Sheet2!A$2:A))&"'", 0),
REGEXEXTRACT(INDIRECT("A"&ROW()), "- (.+)"))))

How to apply Entity_Filter as OR in Dynamics NAV WebService

I am consuming a Dynamics NAV 2009 WebService (SOAPish). Specific I am talking about the ReadMultiple method MSDNA
The filterArray takes an array of Entity_Filter objects. Each Entity_Filter has a Field and Criteria property.
Now I want to know, how I can apply the filters as OR not and.
For Example I am passing two filters:
Entity_Filter { Field: "Name", Criteria: "*banana*" }
Entity Filter { Field: "Color", Criteria: "yellow"}
If I send this to the ReadMultiple I get all entries that have "banana" as part of the name AND the color yellow. What do I have to do, to get all Entries that have "banana" as part of the name OR the color yellow?
Unfortunately, there is no way to apply an 'OR' filter on a record. ReadMultiple method applies filters the same way C/AL methods SETFILTER or SETRANGE do. It has to be done in two separate requests.
On the second thought, you can do it in a single request, but with an OData service using Linq:
NAV nav = new NAV(new Uri("http://ServerName:Port/DynamicsNAV71/OData/Company('Your Company Name')"));
nav.Credentials = CredentialCache.DefaultCredentials;
var items = from i in nav.ItemsList where i.Name.Equals("Banana") || i.Color.Equals("Yellow") select i;
Where 'ItemsList' is an OData web service of type 'Page'