Forum Discussion

anu2021's avatar
anu2021
Frequent Visitor
1 year ago
Solved

Help with Excel formula

I am trying to do a date mapping in the following data basis the the value present fields...  Value > 0 , the first value month will start month and the last value >0 should be the end month.. Sample data i have given... Could you please help

 

Identity1-Jan-251-Feb-251-Mar-251-Apr-251-May-251-Jun-251-Jul-251-Aug-251-Sep-251-Oct-251-Nov-251-Dec-251-Jan-261-Feb-26Start PeriodEnd period
Item10012222200000025-Mar25-Aug
Item20122222000000025-Feb25-Jul
Item30122222000000025-Feb25-Jul
Item40000012222200025-Jun25-Nov
Item50000012222211025-Jun26-Jan

 

  • Hi anu2021 

    Can you please try the below steps to get your requirement ?

    1. Use below formula to get Start Period

    =TEXT(INDEX($B$1:$O$1, MATCH(TRUE, INDEX(B2:O2>0, 0), 0)), "yy-mmm")

    2. Use below formula to get End Period
    =TEXT(INDEX($B$1:$O$1, MATCH(1, INDEX((B2:O2>0)*(COLUMN(B2:O2)=MAX(IF(B2:O2>0, COLUMN(B2:O2)))), 0), 0)), "yy-mmm")

     



    If this answers your questions, kindly accept it as a solution and give kudos.


    I have also attached the excel file.

6 Replies

  • jaineshp's avatar
    jaineshp
    Memorable Member

    Hey anu2021,

    Could you please attach the excel file instead of image?

    Image won't help understand the scenario.

    Best regards,
    Jainesh Poojara / Power BI Developer

    • anu2021's avatar
      anu2021
      Frequent Visitor

      i am unable to attach the file.. so tried pasting it in table view instead of Image.. 😞

  • Hi anu2021 

     

    Please provide a workable sample data (not an image), your expected result from the same sample data and your reasoning behind. The sample data must actually represent your raw data and not simply the desired output. You may post a link to Excel or a sanitized copy of your PBIX stored in the cloud. Also, your image is very hard to read

     

    • anu2021's avatar
      anu2021
      Frequent Visitor

      hi, I am trying to attach the file.. however i am not finding an option to attach.. so updated it with the table view intead of image..

  • Hi anu2021 

    Can you please try the below steps to get your requirement ?

    1. Use below formula to get Start Period

    =TEXT(INDEX($B$1:$O$1, MATCH(TRUE, INDEX(B2:O2>0, 0), 0)), "yy-mmm")

    2. Use below formula to get End Period
    =TEXT(INDEX($B$1:$O$1, MATCH(1, INDEX((B2:O2>0)*(COLUMN(B2:O2)=MAX(IF(B2:O2>0, COLUMN(B2:O2)))), 0), 0)), "yy-mmm")

     



    If this answers your questions, kindly accept it as a solution and give kudos.


    I have also attached the excel file.

    • anu2021's avatar
      anu2021
      Frequent Visitor

      This helps and solves the problem for 2 lakh+ records... Thank you 🙂