Filemaker self join portal filtering - filter

I have a database of items that are imported from a number of XML sources, into a table called Import.
Each XML source has its own SourceID number. This number is put in every item record.
Each import is logged in a related table called Import_History. This logs the SourceID, date of each import, and how many items were imported.
So...
TABLE: IMPORT
SourceID = Number
TABLE: IMPORT_HISTORY
fk_SourceID = Number
ImportDate = Timestamp
ImportCount = Number
RELATIONSHIP
Import::SourceID = Import_History::fk_SourceID
WHAT I NEED
On the Import table layout, I want a portal that shows records from Import_History so I can see when each XML source was last imported. I only want to show the most recent Import_History record for each SourceID.
I think I need a cartesian join between Import and a new table occurence of Import_History (Import_History_All), and a self join of a new table occurence of Import_History (Import_History_All_Self_Join).
So...
Cartesian
Import::SourceID x Import_History_All::fk_SourceID
Self Join
Import_History_All::fk_SourceID = Import_History_All_Self_Join::fk_SourceID
WHAT I'VE DONE SO FAR
I have followed this:
http://www.filemakertoday.com/com/archive/index.php?t-32667.html
and this:
http://scarpettagroup.com/filemaker-portal-show-distinct-value-tutorial/
But it does not filter the records. I always get all of the Import_History records in the portal. I have endlessly googled and not figured this out.
Can anyone help?
**EXAMPLE DATA**
*Import*
- SourceID: 1234
- Item: Widget1
- Price: 3
- SourceID: 1234
- Item: Widget2
- Price: 5
- SourceID: 1234
- Item: Widget3
- Price: 10
*Import_History*
- fk_SourceID: 1234
- ImportDate: 22/03/2016 12:00:00
- ImportCount: 3
- fk_SourceID: 1234
- ImportDate: 21/03/2016 12:00:00
- ImportCount: 2

Import_History_All::fk_SourceID = Import_History_All_Self_Join::fk_SourceID
The relationship above is a join that will result in every record with the specified source ID being displayed in the portal. Basically the relationship above will display the designated portal records in the IMPORT HISTORY table that have the same SourceID. If you wanted to view the most recent record for the sourceID of the record you are on this would be the relationship that is required, and all that would be left is sorting the portal and filtering to only show the most recent value. This would be fine, if you wanted only the most recent importation for the SourceID you are currently on.
On the Import table layout, I want a portal that shows records from Import_History so I can see when each XML source was last imported. I only want to show the most recent Import_History record for each SourceID.
The most efficient way to display only the most recent record of each SourceID would be to utilize another table to store the most recent values. This table would contain records with unique values for Source ID ( each source has only one record ) that would contain the Import ID of the most recent record. The import ID is a primary key for the Import_History table that you would add to define a distinction between each Import_History record. Modification of your current importation script is necessary to achieve this result. The modifications should include a variable that captures the Import_ID. The relationship between the tables Import and Import_Tracking will only bring up one record, and then you can use the set field script step to set the field Import_Tracking::Most_Recent to the previously defined variable that holds the value of Import_ID. At this point you have the Import_Tracking table, which contains the unique Import_ID of the most recently updated record for each source. You can use a Cartesian join in the Import table with the Import_Tracking table to show all the records in the Import_Tracking table, which only has the most recent importID for each unique source. If you want to see data from the Import_History table all that you need to do is create a relationship between the Import_Tracking and Import_History table, and then you can place related fields inside of your portal to view the data. I have included the relationships and fields that should be added below. Please let me know if anything doesn't make sense.
RELATIONSHIP:
Import::SourceID = Import_Tracking::fk_SourceID (w/ ability to add records via relationship)
Import_Tracking::Most_Recent = Import_History::ImportID
TABLE: IMPORT_HISTORY
fk_SourceID = Number
ImportDate = Timestamp
ImportCount = Number
ImportID = Text/Number (Primary Key)
TABLE: IMPORT_TRACKING
fk_SourceID = Number
Most_Recent = Text/Number (Whatever you defined "ImportID" as)

I want a portal that shows records from Import_History so I can see
when each XML source was last imported. I only want to show the most
recent Import_History record for each SourceID.
If you sort the related records from Import_History by ImportDate (in the relationship setup), then the most recent import will become the first related record.
If you place fields from Import_History directly onto a layout of the Import table (outside of any portal), they will show data from the first related record in Import_History.
This presumes one simple relationship where:
Import::SourceID = Import_History_All::fk_SourceID
I don't see why you would need any other.

Related

D365/Dataverse - Create Calculated/Look Up Column that is set to the highest date in another table

I have Table 1. It is filled with dates a inspection is going on. Plumbing or Garden inspections for example.
Table 2 links to these appointments and has additional columns with details such as a Person assigned to the inspection, and what property the inspection is at. I need these two tables to be separate as described, and they are linked by a simple ID column.
Is it possible at all to add a column to Table 2 called 'Last Date of Plumbing Inspection'. The idea is for any given Property in Table 2, there can be multiple inspection entries in Table 1 for it. The point of this column is that it should look in Table 1, find the matching ID, find the latest inspection date out of all the Plumbing-related inspections, and then set the column value to that.
The problem I am having with this is it seems like calculated columns can ONLY implement logic using the columns of the table the calculated column was created in. In Table 2, I can't create a calculated column that interacts with Table 1 at all. I could create a look up column, but I can't combine calculated columns with look up columns. Is there a way to build this latest inspection date column without too much complexity?
Actually you can create a Rollup field and put a MAX aggregate function for achieving your requirement from related table. Read more

Create a summary table based on data from another table in Power Query

I am new and pretty inexperienced with Power Query, so have struggled with this issue and finding a basic tutorial on Power Query.
I am using Power Pivot to analyse some data. My source data is added to the Excel Data Model using Power Query from an external CSV file.
What I want to be able to do is create a summary table from the source data in a new table. This new table would be added to the data model. My source table (SrcTable) would look like this;
Order ID
Item Code
O-001
I-001
O-001
I-002
O-002
I-001
O-003
I-001
O-003
I-002
O-003
I-003
My new table would have two columns
A list of each Item Code
A Distinct Count of Order ID for each Item Code
So for the example above the SummaryTable would look like this
Item Code
Num Orders
I-001
3
I-002
2
I-003
1
Can someone please give me some guidance on how can I write a query to create this new table for me?
Thanks
Select your table using data...from table/range... to get it into powerquery
In powerquery
right click the Item Code column and choose Group by...
It should default to doing a count. You can change the name of the column from Count to Num Orders if you want. Then Hit Ok
The do File .. close and load to ... and decide how you want to get the data back into Excel. There is an optional [x] checkbox to add the data to data model

Google Sheets - Automatically sort columns NEXT TO a Query so that the entire range re-orders together in real-time

TEST sheet
Tab 1 = Registration data
Tab 2 = Attendance sheet
A4 uses Query() to pull the appropriate student data into that sheet. As more students enroll, it will automatically re-sort based on School then Name.
The actual attendance (Columns D:H) are manually entered.
Goal: I would like for the data in Columns D:H to automatically re-sort and follow the students as they re-sort....is this possible??!!

Custom function by date for related tables

"In a crosstab, latest month where Actuals has any data, show Actuals data for that and all previous months. Future months, show Forecast data."
.
I have two tables- Forecasts and Actuals- and the common columns between them are Team, Month, Value.
I'd like to show the data in a crosstab with Month as columns and Team as rows. I'm trying to write an expression to do this in the crosstab: The most recent month where Actuals has any data, I'd like to show Actuals data for that and all previous months, for all teams. For following months, I'd like to show Forecast data.
Any suggestions about how to go about this would be appreciated. I'm still piecing together my knowledge :)
Create a third table from a transformations:
Create Third table from - Pivot date on Team & Month (to ensure every possible combination) from first table
Add Rows from transforming the second table (pivot on Team & Month)
Join the two original tables to your newly created table (has every possible combination of Team & Month) so that both your data sets are now in one table.
Now use the third table in your cross table.
If you try using column matching instead of the above method only dates from the main table will show as the dates are matched and ones missing from the other will not display.

SSRS Tablix Cell Calculation based on RowGroup Value

I have looked through several of the posts on SSRS tablix expressions and I can't find the answer to my particular issue.
I have a dashboard I am creating that contains summary data for various managers. They are entering monthly summary data into a single table structured like this:
Create TABLE OperationMetrics
AS
Date date
Plant char(10)
Sales float
ReturnedProduct float
The data could use some grouping so I created a table for referencing which report group these metrics go into looks like this:
Create Table OperationsReport
as
ReportType varchar(50)
MetricType varchar(50)
In this table, 'Sales' and 'ReturnedProduct' are the Metric column, while 'ExecSummary' or 'Quality' are ReportType entries. To do the join, I decided to UNPIVOT the OperationMetrics table...
Select Date, Plant, Metric, MetricType
From (Select Date, Plant, Sales, ReturnedProduct From OperationMetrics)
UNPVIOT (Metric for MetricType in (Sales, ReturnedProduct) UnPvt
and join it to the OperationsReport table so I have grouped metrics.
Select Date, Plant, Metric, Rpt.MetricReport, MetricType
FROM OpMetrics_Unpivoted OpEx
INNER JOIN OperationsReport Rpt on OpEx.MetricType = Rpt.MetricType
(I understand that elements of this is not ideal but sometimes we are not in control of our destiny.)
This does not include the whole of the tables but you get the gist. So, they have a form they fill in the OperationMetrics table. I chose SSRS to display the output.
I created a tablix with the following configuration (I can't post images due to my rep...)
Date is the only column group, grouped on 'MMM-yy'
Parent Row Group is the ReportType
Child Row Group is the MetricType
Now, my problem is that some of the metrics are calculations of other metrics. For instance, 'Returned Product (% of Sales)' is not entered by the manager because it is assumed we can simply calculate that. It would be ReturnedProduct divided by Sales.
I attempted to calculate this by using a lookup function, as below:
Switch(Fields!FriendlyName.Value="Sales",SUM(Fields!Metric.Value),
Fields!FriendlyName.Value="ReturnedProduct",SUM(Fields!Metric.Value),
Fields!FriendlyName.Value="ReturnedProductPercent",Lookup("ReturnedProduct",
Fields!FriendlyName.Value,Fields!Metric.Value,"MetricDataSet")/
Lookup("Sales",Fields!FriendlyName.Value,Fields!Metric.Value,
"MetricDataSet"))
This works great! For the first month... but since Lookup looks for the first match, it just posts the same value for the rest of the months after.
I attempted to use this but it got me back to where I was at the beginning since the dataset does not have the value.
Any help with this would be well received. I would like to keep the rowgroup hierarchy.
It sounds like the LookUp is working for you but you just need to include the date to find the right month. LookUp will return the first match which is why it's only working on the first month.
What you can try is concatenating the Metric Name and Date fields in the LookUp.
Lookup("Sales" & CSTR(Fields!DATE.Value), Fields!FriendlyName.Value & CSTR(Fields!DATE.Value), Fields!Metric.Value, "MetricDataSet")
Let me know if I misunderstood the issue.

Resources