To Apply formula in Pivot column

  • [HR][/HR]Hello Expert,

    Requirement: I have a workbook with many pivots many it. Each of the pivots has a field “Request No”. This field has an embedded hyper link in the source data sheet, which when clicked direct us to source.


    But when I pivot this data, hyperlink is lost. I need to activate this hyperlink in pivot so can think of following code


    Need you help to guide me on how to build up a macro code for following steps.


    For each pivot in the workbook,
    Look for Pivot field= “Request No”
    For All Request No in that column
    Apply formula =HYPERLINK(CONCATENATE("http://cormel- itg01:8080/itg/web/knta/crt/RequestDetail.jsp?REQUEST_ID=",Request No),Request No)


    This would help me to replace the entire request No with the hyperlink for all the pivots in the workbook.


    Appreciate your support on above.


    Many thanks !

    Cheers,
    Alka

  • Re: To Apply formula in Pivot column


    You can't enter a formula for an item name in a pivot table.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: To Apply formula in Pivot column


    Ok. How in this case I can take out the request No from the Piviot row label, and add in as a last column in the pivot
    "Request No" and apply following formula to retrieve the data along with the hyperlink.
    =HYPERLINK(CONCATENATE("[URL="http://cormel-itg01:8080/itg/web/knta/crt/RequestDetail.jsp?REQUEST_ID=",VLOOKUP(F9,'Issue"]http://cormel-itg01:8080/itg/w…estDetail.jsp?REQUEST_ID=",VLOOKUP(F9,'Issue[/URL] Query Risk'!F:N,9,FALSE)),VLOOKUP(F9,'Issue Query Risk'!F:N,9,FALSE))


    Hence to summarize ,can we automate below,
    to traverse through all the pivots of all the sheets in the workbook and add the additional column at the end of the pivot with the above formula.


    Steps Required:
    For each pivot in the workbook,
    Add Request No as the last column
    Apply formula =as mentioned above,



    Regards,
    Alka

  • Re: To Apply formula in Pivot column


    What is F9 supposed to be?

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: To Apply formula in Pivot column


    I know that, but it's a relative reference, so is every formula added next to a pivot table supposed to refer to cell F9 specifically, or is it supposed to be relative to where the formula is added?

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: To Apply formula in Pivot column


    My bad.It would be different for different pivots. Formula has to be relative depending on pivot & data location.
    In this case we need to Lookup_value in reference to the column " SHort Description"


    All pivots would have this column as their row data.



    Thanks again for all the help!

  • Re: To Apply formula in Pivot column


    Can you post a sample workbook for testing and so that I can see the layout you have? Depending on the pivot setup, a simple formula may work, or the code may need to find and store the lookup values.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: To Apply formula in Pivot column


    Hi Rory,


    I am unable to attach the file to this forum, Please let me know if I can mail you.


    Appreciate your support on this. Really required.


    Thanks.


    Regards,
    Alka

  • Re: To Apply formula in Pivot column


    Why can't you attach a file? If it is due to size, try using ZIP compression or a an online service.


    The workbook should contain fake data, but exactly duplicate the structure and data types and contain only enough data to illustrate the problem.


    [COLOR="navy"]How to edit your post or thread title or upload an attachment[/COLOR]


    1. Click the EDIT POST in the gray band immediately below your post
    2. Click Go Advanced
    3. Edit the post or thread title
    4. To upload: scroll down to Manage Attachments

  • Re: To Apply formula in Pivot column


    Try this:

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: To Apply formula in Pivot column


    Thanks Rory for the VB. It works as expected.


    However, appreciate if you let me know how to resolve below


    1. Inserted column, requires few formating as highlighted in attached.
    2. Also, pivots will be usually filtered based on certain fields. When I run this macro, only the displayed rows fetchs the request no. In an event, when someone unfilter the field, then the request no is not displayed correctly, until n unless the macro is re-run.



    Thanks again for the help.


    Regards,
    ALKA

  • Re: To Apply formula in Pivot column


    Re #2, you'll have to run the code again - using the worksheet's pivottableupdate event is probably easiest.I'll look at the formatting when I'm at a computer.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: To Apply formula in Pivot column


    Change the ProcessPivot routine to:


    and then in the ThisWorkbook module, add this:

    Code
    Private Sub Workbook_SheetPivotTableUpdate(ByVal Sh As Object, ByVal Target As PivotTable)
       ProcessPivot Target
    End Sub

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: To Apply formula in Pivot column


    Thanks Rory.


    But I am getting an error at
    .Resize(.Rows.Count - 1).Style = "Hyperlink".


    Also, wrt # 2. I need to run the code again everytime? What is worksheet's pivottableupdate event ? Is it a normal pivot refresh?

  • Re: To Apply formula in Pivot column


    What error are you getting?

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: To Apply formula in Pivot column


    I mean, what is the error message? The code works fine for me (see attached version of your file).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!