Tableau exclude column in calculation - tableau-api

month name fruit eaten amount paid
Jan-19 john apple 3
Jan-19 jim orange 7
Jan-19 king apple 6
Feb-19 john berry 5
Feb-19 jim mango 7
Feb-19 king pawpaw 8
Mar-19 john apple 5
Mar-19 jim melon 7
Mar-19 king lemon 9
solution I want:
Name latest fruit eaten (Mar-19) Year to date Total spent by Name
john apple 13
jim. melon 21
king lemon 23
Please I want to summarize the values based in the image only include the maximum or latest value of one column.
Thanks

Place month filter and select March, now place name and fruit on rows.
Create a calculated field amount and write below:
{ FIXED [fruit]:SUM([amount])}
Place it on marks
Edit-------------------------------------------------------------------
calculated field:

Related

how to have a item represented as value in time series grafana?

So I have this table:
ID sale_date item price
-------------------------------
1 2022-11-01 apple 2.11
2 2022-11-02 apple 2.61
3 2022-11-03 apple 2.91
4 2022-11-04 apple 2.51
5 2022-11-01 orange 3.23
6 2022-11-02 orange 2.75
7 2022-11-03 orange 3.01
8 2022-11-04 orange 3.51
9 2022-11-01 banana 1.93
10 2022-11-02 banana 2.22
11 2022-11-03 bananna 2.13
12 2022-11-04 banana 1.53
I am trying to create a query that will display in a Grafana time series graph measuring the price for apple, orange and bananas overtime.
my query:
SELECT
$__time(sale_date),
item,
price
from mytable
group by sale_date, item, price
I am trying to achieve a time series similar to this:
any help is appreciated :)
This will be good start - aggregated avg price per day:
SELECT
$__timeGroupAlias(sale_date, '1d'),
item as "metric",
AVG(price) AS "value"
FROM mytable
WHERE
$__timeFilter(sale_date)
GROUP BY 1, 2
ORDER BY 1
You may still need to tweak it, because your sale_date datatype is unknown. Eventually, you may need different macro.

PostgreSQL LAG records one year apart by partitioning

I have a db table with a bunch of records in a snapshot fashioned way, i. e. daily captures of product units availability for many years
product units category expire_date report_date
pineapple 10 common 12/25/2021 12/01/2021
pineapple 8 common 12/25/2021 12/02/2021
pineapple 8 deluxe 12/28/2021 12/02/2021
grapes 45 deluxe 11/30/2022 12/01/2021
...
pineapple 21 common 12/12/2022 12/01/2022
...
What I'm trying to get from that data is something like this "lagged" version, partitioning by product and category:
product units category report_date prev_year_units_atreportdate
pineapple 10 common 12/01/2021 NULL
pineapple 21 common 12/01/2022 10
pineapple 16 common 12/01/2023 21
...
It's important to know that from time to time the cron snapshot task fails and no records are stored for days. This leads to a different number of records by product.
I've been using LAG() to no avail since I can only get previous day/month using partitioning by product, category
Can anyone help me on this?
I think I would use a subselect rather than a window function.
select *,
(
select units from t t2
where t2.report_date=t1.report_date-interval '1 year' and t2.product=t1.product and t2.category=t1.category
) lagged_units
from t as t1
I'm not sure what you want to happen on leap year, though, or the year after one.

Problems with an m:m Merge (Stata)

I am trying to the merge two datasets that have unemployment rates from different sources, and the first is structured as below:
It has over 30 variables but I am only listing this as an example. In addition, each observation is measured at one year only, for Egypt it is 2005.
year country Gender Unemployment
2005 EGY Female 7.6
2005 EGY Male 9.2
2005 EGY Total .
2006 EGY Female 7.6
2006 EGY Male 9
2006 EGY Total .
The second is structured as below, but it comes from an annual survey, so each country has three entries per year (total, male, female). And each country has from 1995-2019.
country Gender year Unemployment
EGY Total 2005 12
EGY Male 2005 7
EGY Female 2005 17.5
Therefore, I tried to merge the two datasets with 1:1 and 1:m merge, and for both I get:
"variables country year do not uniquely identify observations in the master data"
However, the merge worked with a m:m as in below,
merge m:m country year using "Documents\LMI.dta"
Thanks to Nick's advice, I merged with the triples:
merge 1:1 country year Gender cusing "Documents\LMI.dta"
And it worked well!
On the face of it your datasets are identified by triples of country year Gender and so qualify for merge 1:1 with those variables. So, the downside of an m:m merge appears to be that it is quite wrong.
That statement doesn't solve any of the problems that come next:
Unemployment is so named in both sets, so what do you expect or want Stata to do?
In your data example, the values of Unemployment are different in different datasets, although perhaps this is not true of the real data.

How to find group wise total(Sum) in SAP crystal report?

How to find group wise total(Sum) in SAP crystal report?
Dear All,
I have to find the Sum of value based on the Date(01/01/2014……) And Regional (North,West,East,Central) wise….But 2014,2013 column data type varchar(25)
Here I will give little Example of what I want to do:
Date Regional StationName 2014 2013
01/01/14 North AAA 1000.00 100.20
01/01/14 North BBB 500.00 50.00
1500.00 150.2
01/01/14 West ZZZ 100.00 00.00
01/01/14 West YYY 500.00 10.00
600.00 10.00
Grand Total :2100.00 160.2
to get that done you will have to create 2 groups, one by Date(suppressed) and another by Regional where you are going to place all of your fields. Then crate to formulas, one for 2014 and another for 2013 columns to convert those strings to number using tonumber() function. For example tonumber(2014). Then you will have to summarize 2014 and 2013 based on Regional Group and grand totals for both as well.

crystal report display count of records

I have crystal generating the following output in my Details section
Cats Group
Number How Old
________________________
12 0-30 days old
32 0-30 days old
34 31-60 days old
Dogs Group
Number How Old
________________________
22 over 61 days old
123 0-30 days old
but i need the above info in a table format
Group 0-30 days old 31-60 days old over 61 days old
______________________________________________________
Cats 2 1 0
Dogs 1 0 1
thanks
You need a Cross-Tab;
Open Cross-tab expert
Drag group into columns
Drag animal type into rows
Drag animalinto value and set count as summarize option