Conditional summing in FileMaker Pro 14 - sum

I want to know how do you get conditional sums on FM 14, because I can´t find anything.
I have X number of records in a layout. Each record has Price, Name and Month. I want to create another layout in which I will have a table with the months arranged horizontally and Name arranged Vertically. Like this:
January February March April .... .... .... December
Name 1 (calc)
Name 2 (calc)
Name 3 (calc)
....
....
....
Name X
(calc) = Calculation
I want to sum every price on each record that has the Name and Month specified in each calculation.
I can´t find the way to do it and it´s driving me crazy.
Thanks

Create 12 calculation fields with formula:
If( myTable::Month = 'January'; myTable::Price ; "" )
(repeat for every month)
Create a list layout based on the same table, with header and footer
Add sub-summary when sorted by Name
Add to sub-summary Name field
Create a summary fields for every earlier created calculation fields based on Sum()
Add these summary fields to sub-summary layout part
Delete Body layout part
Sort records by Name

Filemaker is not very good at cross-tab reports, Still, here's one way to look at it:
Define a calculation field cSplitByMonth (result is Number, Number of repetitions: 12) =
Let ( [
monthNames = "January¶February¶March¶April¶May¶June¶July¶August¶September¶October¶November¶December" ;
monthName = GetValue ( monthNames ; Get ( CalculationRepetitionNumber ) )
] ;
If ( Extend ( Month ) = monthName ; Extend ( Price ) )
)
Define a summary field as Total of cSplitByMonth, summarize repetitions individually.
Create a layout with a sub-summary part (when sorted by name) and no body part. Place the Name field and the summary field (with all its 12 repetitions, oriented horizontally) in this part.
Sort the records by Name.
Another approach can be seen here: http://fmforums.com/topic/71836-getting-more-out-of-filtered-portals-in-version-11/#comment-339728

Related

How to let user select columns to be displayed in table on Qliksense?

I have a table with a large number of columns so I would like to have a filterpane/listbox with all the dimensions and measures allowing the user to select the columns they would like to see in the table.
My table looks like this where the columns are displayed based on the selection:
So something like this:
I tried to do it using this solution but it does not appear to do anything. Can someone tell me where I'm going wrong?/How can I do this?
Here is my script in the load editor where I create the table for the selection:
Selection:
load * inline [
Dimension
Category
Revenue
Year
ProductName
ProductID
Date
];
Here is my condition for each of the columns in the table, using column ProductID as an example:
=SubStringCount(Concat(Measure),1), ProductID)
You can try this:
Set vShowCollumn = Not IsNull(GetFieldSelections($1)) and WildMatch(Concat($2,','),'*$3*');
I_DIMENSIONS:
Load
*
InLine [
_Dimension , _CodDimension
Product , 001
Shop , 002
];
and in the product you choose de number, respondind with your inline, for example:
$(vShowcollumn(_Dimension,_CodDimension,001))
so, when it gonna show only when user click in the dimension.

Perform calculation without having to do it manually for each column?

I have the following view set up in SQL Server:
VIEW
(left table: population data per year; middle table: municipalities; right table: municipality areas in km²)
Query
SELECT
dbo.T_GEMEINDE.GKZ, dbo.T_GEMEINDE.NAME,
dbo.T_BASE_DAUERSIEDLUNGSRAUM_GEMEINDE.FLAECHE_KM2 / dbo.T_BASE_DAUERSIEDLUNGSRAUM_GEMEINDE.DAUERSIEDLUNGSRAUM_KM2 AS [ges. Fläche / Dauersiedlungsr.],
dbo.T_BASE_GEMEINDE_BEVOELKERUNG_JAHR_BEGINN.J2017 / dbo.T_BASE_DAUERSIEDLUNGSRAUM_GEMEINDE.FLAECHE_KM2 AS [ges. Bevölkerungsdichte],
dbo.T_BASE_GEMEINDE_BEVOELKERUNG_JAHR_BEGINN.J2017 / dbo.T_BASE_DAUERSIEDLUNGSRAUM_GEMEINDE.DAUERSIEDLUNGSRAUM_KM2 AS [Bevölkerungsdichte Dauersiedlungsraum]
FROM
dbo.T_BASE_DAUERSIEDLUNGSRAUM_GEMEINDE
INNER JOIN
dbo.T_GEMEINDE ON dbo.T_BASE_DAUERSIEDLUNGSRAUM_GEMEINDE.GKZ = dbo.T_GEMEINDE.GKZ
INNER JOIN
dbo.T_BASE_GEMEINDE_BEVOELKERUNG_JAHR_BEGINN ON dbo.T_GEMEINDE.GKZ = dbo.T_BASE_GEMEINDE_BEVOELKERUNG_JAHR_BEGINN.GKZ
The last column in the view contains a calculation (population density for 132 municipalities for a certain year) for the year 2017 and uses the column J2017 from the table seen on the left. This is the output (Bevölkerungsdichte Dauersiedlungsraum):
Current output:
OUTPUT
Desired output:
The rightmost column (Bevölkerungsdichte Dauersiedlungsraum) seen in the provided output screenshot has the output data of the calculation for the year 2017. The same output has to be generated for all the other years, but each as a separate column.
Question: how do I perform the calculation which you can see in the last column in the view for all years (J2017-J2050) without having to do it manually for each year column?
Thanks in advance.
if you want someone to provide you with a complete solution then you will need to supply:
CREATE TABLE statements for the 3 tables
INSERT INTO... statements to provide sample data for all 3 tables
However, if you just want a suggestion about how to approach this problem then I would use an UNPIVOT statement to create a view/table that
holds all the columns in dbo.T_BASE_GEMEINDE_BEVOELKERUNG_JAHR_BEGINN
apart from the "year" columns (J2017, J2018, j2019, ...)
adds a single "year" column with values from 2017 to 2050
adds a single value column to hold the population for each year
By joining your existing tables to this new table/view and grouping by your new "year" column you should achieve what you want

How to output duplicate row count into a custom field in SAP query

Our company runs on SAP ERP 6.0, SAP_BASIS 702, SAP_ABA 702 (2005), just something to keep in mind in regards to the code syntax.
I have a table LTAP, I want to create a query based on this table, which would produce "N" as number of picks that occured in the past month from the day the report is ran.
I've defined the dynamic date with the following:
YEAR = SY-DATUM(4).
MTH = SY-DATUM+4(2).
DAY = SY-DATUM+6(2).
IF MTH EQ 1.
MTH1 = MTH + 11.
ELSE.
MTH1 = MTH - 1.
ENDIF.
IF MTH eq 1.
YEAR1 = YEAR - 1.
ELSE.
YEAR1 = YEAR.
ENDIF.
FROM_DATE(4) = YEAR1.
FROM_DATE+4(2) = MTH1.
FROM_DATE+6(2) = DAY.
Which seems to do the job.
What I can't seem to get working is to get the count of duplicate lines of field MATNR (each line entry represents a unique pick) and output it to a custom field, while removing the duplicate rows and keeping just the unique values.
Example of what I mean:
I'd like to do this while respecting the date range above and be doable within the sq01/sq02.
How to output duplicate row count into a custom field in SAP query?

SAP BO - how to get 1/0 distinct values per week in each row

the problem I am trying to solve is having a SAP Business Objects query calculate a variable for me because calculating it in a large excel file crashes the process.
I am having a bunch of columns with daily/weekly data. I would like to get a "1" for the first instance of Name/Person/Certain Identificator within a single week and "0" for all the rest.
So for example if item "Glass" was sold 5 times in week 4 in this variable/column first sale will get "1" and next 4 sales will get "0". This will allow me to have the number of distinct items being sold in a particular week.
I am aware there are Count and Count distinct functions in Business Objects, however I would prefer to have this 1/0 system for the entire raw table of data because I am using it as a source for a whole dashboard and there are lots of metrics where distinct will be part/slicer for.
The way I doing it previously is with excel formula: =IF(SUMPRODUCT(($A$2:$A5000=$A2)*($G$2:$G5000=$G2))>1,0,1)
This does the trick and gives a "1" for the first instance of value in column G appearing in certain value range in column A ( column A is the week ) and gives "0" when the same value reappears for the same week value in column A. It will give "1" again when the week value change.
Since it is comparing 2 cells in each row for the entire columns of data as the data gets bigger this tends to crash.
I was so far unable to emulate this in Business Objects and I think I exhausted my abilities and googling.
Could anyone share their two cents on this please?
Assuming you have an object in the query that uniquely identifies a row, you can do this in a couple of simple steps.
Let's assume your query contains the following objects:
Sale ID
Name
Person
Sale Date
Week #
Price
etc.
You want to show a 1 for the first occurrence of each Name/Week #.
Step 1: Create a variable with the following definition. Let's call it [FirstOne]
=Min([Sale ID]) In ([Name];[Week #])
Step 2: In the report block, add a column with the following formula:
=If [FirstOne] = [Sale ID] Then 1 Else 0
This should produce a 1 in the row that represents the first occurrence of Name within a Week #. If you then wanted to show a 1 one the first occurrence of Name/Person/Week #, you could just modify the [FirstOne] variable accordingly:
=Min([Sale ID]) In ([Name];[Person];[Week #])
I think you want logic around row_number():
select t.*,
(case when 1 = row_number() over (partition by name, person, week, identifier
order by ??
)
then 1 else 0
end) as new_indicator
from t;
Note the ??. SQL tables represent unordered sets. There is no "first" row in a table or group of rows, unless a column specifies that ordering. The ?? is for such a column (perhaps a date/time column, perhaps an id).
If you only want one row to be marked, you can put anything there, such as order by (select null) or order by week.

Qlikview calculation of range for frequencies

I am given a task to calculate the frequency of calls across a territory. If the rep called a physician regarding the sale of the product 5 times, then frequency is 5 and HCP count is 1....I generated frequencies from 1 to 124 in my pivot table using a calculated dimension which is working fine. But my concern is :
My manager wants frequencies till 19 in order from 1..2..3..4...5..6.....19...
And from the frequency 21-124 as 20+.
I would be grateful if someone helps me with this.....Eager for the reply....
Use the Class function in the dimension, to split into buckets:
=class(CallId,5)
And the expression:
=count(Distinct CallId)
You can then customize the output by adding parameters:
class( var,10 ) with var = 23 returns '20<=x<30'
class( var,5,'value' ) with var = 23 returns '20<= value <25'
class( var,10,'x',5 ) with var = 23 returns '15<=x<25'
I think you can do this with a calculated dimension.
If your data has one row per physician coming from the load statement below will likely work.
Dimension
- =IF(CallCount<=19,CallCount,'+20')
Expression
- =COUNT(DISTINCT Physician_ID)
Sort
- Numeric Value Ascending
If your data has to be aggregated, more than one call row per provider incoming from the load try above substituting below for the Dimension.
Dimension
- =IF(AGGR(SUM(CallCount), Physician_ID) <=19,AGGR(SUM(CallCount), Physician_ID),'+20')