PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 3, 2022

[FIXED] How to get the last row per group of category?

 November 03, 2022     count, google-sheets, lambda, partition, rank     No comments   

Issue

I want to label the last column with value 1 for the last record for each jobID, Product, Target. Please refer to table below.

JobID Product Target Expected Output
1 ABC1 0
1 ABC1 0
1 ABC1 0
1 ABC1 0 1
2 ABC2 2
2 ABC2 2
2 ABC2 2
2 ABC2 2 1
3 ABC3 1
3 ABC3 1
3 ABC3 1
3 ABC3 1 1

The target will always remain the same per jobid and product so it is basically repeating. I need to label the value 1 as shown in expected output for the last record per JobID, Product and Target. How can I achieve this in google sheets?


Solution

try the reverse search feature of XMATCH:

=INDEX(IFERROR(1/(1/LAMBDA(x, XMATCH(x, x,,-1)=SEQUENCE(ROWS(x)))(A2:A)*1)))

enter image description here

or:

=INDEX(IF(A2:A="",,IF(COUNTIFS(A2:A, A2:A, ROW(A2:A), ">="&ROW(A2:A))=1, 1, )))

enter image description here



Answered By - player0
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing