
1. Re: How to calculate the first value by category?
Zhouyi Zhang Jul 2, 2018 5:01 AM (in response to Simin Xu)1 of 1 people found this helpfulHi, Simin
try below calculation for cal1
{Fixed [city],[first_week],[pay_type]:min(if [first_week] = [week_no] then [total_num] end)}
Please let me know if it works or not.
ZZ

2. Re: How to calculate the first value by category?
Jim Dehner Jul 2, 2018 5:03 AM (in response to Simin Xu)Good morning I think I understand
have you tried {fixed [city],[pay_type] : if Min( [week_no] )=min([firstweek]) then sum([total_number]) }
Jim
If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution. Thank you.

3. Re: How to calculate the first value by category?
Simin Xu Jul 3, 2018 2:31 AM (in response to Zhouyi Zhang)This is workable. Thanks!
just need to change min to max:
{Fixed [city],[first_week],[pay_type]:max(if [first_week] = [week_no] then [total_num] end)}
Simin

4. Re: How to calculate the first value by category?
Zhouyi Zhang Jul 3, 2018 4:35 AM (in response to Simin Xu)Hi, Simin
Glad it works.
In your sample data, min/max is really doesn't matter. But probably your real data max makes more sense.
If this is the correct answer, can you mark it as correct to close the thread?
ZZ