Forum Discussion
Help with Excel formula
- 8 months ago
Hi anu2021 ,
Quick Note: I noticed you posted this in the Power BI Community, but specifically asked for an Excel formula. I have provided the Excel solution below to help you out. However, for future Excel-specific questions, you will get faster and more specialized answers in the Microsoft Excel Community.
Now, to your solution!
You are essentially trying to convert a "relative" timeline (Month 1, Month 2) into an "absolute" calendar timeline (Jan 25, Feb 25).
The Excel Solution We need a formula that calculates the month difference between your Header Date and your Start Date to pick the correct value.
Assuming your data layout:
Start Date: Cell A2
Month 1 to Month 12 Data: Columns C to N (C2:N2)
Target Header (e.g., Jan-25): Cell P1 (Must be a date format)
Paste this into P2:
Excel=LET( MonthIndex, (YEAR(P$1) - YEAR($A2)) * 12 + MONTH(P$1) - MONTH($A2) + 1, IF(AND(MonthIndex >= 1, MonthIndex <= 12), INDEX($C2:$N2, 1, MonthIndex), "") )Pro Tip for Power BI: If you ever need to do this transformation inside Power BI instead of Excel, you wouldn't use formulas. You would use Power Query to "Unpivot" your Month columns. That makes this kind of analysis instant without complex logic!
Here is a reference to the functions used:
Hope this helps!
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
This response was assisted by AI for translation and formatting purposes.
Thank you very much... i was able to get the expected result with the formula you have provided earlier as my sample was given for M1 to M12, whereaas my actual data has till M120... so with this update in the formula it is working 🙂
You are very welcome anu2021 !
I am glad to hear you were able to adapt the logic for 120 months. That is quite a wide dataset!
Just keep that Power Query tip in your back pocket. With 120 columns and 300,000 rows, Excel is performing millions of calculations instantly. If the workbook starts to feel slow or "heavy" in the future, unpivoting that M1-M120 range in Power Query will be the best way to speed it up.
Happy Excelling!