Dynamic Report Filters in Salesforce

I have seen many customers in need to have Dynamic Filter. In Absence of Dynamic filter, many times we end up with creating multiple reports with same format and different condition.

Many time, we need something like get all cases related to Parent Account of Opportunity. We can simply create a report for Case and add Condition for Account Name. Using Some Custom Link, we can always Change Account Name and same report can be used many times.

While navigating to community i found very interesting and useful information regarding dynamic Filter in Reports.I thought that Dynamic Filters inside Salesforce is not possible but It is Possible.

Update – For Lightning Experience URL will look like

https://mydomain.lightning.force.com/lightning/r/Report/00O5C00Um3lUAC/view?fv0={!mergeField}

Salesforce does not have any official documentation on this, but here how it works.

Lets have look in below image:

Dynamic Filter in Reporting
Dynamic Filter in Reporting

Above report have three Filters. First Filter will be considered as “pv0”, second filter will be considered as “pv1” and so on.

In URL, we can provide parameter for Pv0, Pv1 like in above image.

Now, we can create a formula field to create a dynamic link which will open report. Something like

https://ap1.salesforce.com/{!ReportId}?pv0={!MergeField0}&pv1={!MergeField1}

Posted

in

by


Related Posts

Comments

15 responses to “Dynamic Report Filters in Salesforce”

  1. Darah Avatar
    Darah

    brilliant!

  2. venkat Avatar
    venkat

    hi jitendra., this is venkat., i’m new to sfdc, i have some doubts on sfdc., if can u give your mail id through that i will contact u my mailid is kannayyaraj@gmail.com plzz help me..,

  3. teja Avatar
    teja

    hi i want to get the operator value of pno from the user we can get that one in this dynamic report .i am creating the report where user can go to vf page he can enter the aCCOUNT NAME IT WILL take automatically and .incase user need some other logic like not equal to like that how we can do it

  4. SG Avatar
    SG

    Hi Jitendra,

    Thanks for this article. I have a situation where there are many BDMs for them creating the same reports but only changing the owner of the record. Eg. Open Opportunities report for many BDMs according to their opportunities. So I guess i can use dynamic filter for that. Once I create the link, how do I display that on a Dashboard so that whoever click the link will display their report on the dashboad.

    Any help is appriciated,
    Thanks.

    1. Jitendra Zaa Avatar

      In that case, you need to create Visualforce component for Dashboard which will compute report URL dynamically on basis of logged in User.

  5. Subrammanian Somasundara Avatar
    Subrammanian Somasundara

    is it possible to allow user to select two different date field
    created date and lead qualified date , i want the user to select created date from — to —
    and lead qualified date from …. to ….
    user should select the date range

    I want to add the below logic
    (1 AND (2 OR 3) AND 4 AND 5)

    1. Five9 Log equals “True”

    2. Call Result contains “Lead” and created date from —- and to —-

    3. Lead Qualified equals and leaddate from —- and to —-

    4. External ID not equal to “”

    5. Territory Name equals “abc”

  6. Gaurav Nawal Avatar
    Gaurav Nawal

    Hi Jitendra

    I am working around a requirement, where the client wants three to four filters on a report. Say, Zone, Region, State, Product, From Date, To Date.

    So, if the user fills only Zone and hits the button to display the report, can my reports be this dynamic that it adds filter only specific to Zone. I see that in other case, it puts the other filters as blank and thus no data is displayed.

    Please help.

    Thanks.

    1. Prashant Avatar
      Prashant

      Did u get any solution for this?Facing same issue.

      1. Gaurav Nawal Avatar
        Gaurav Nawal

        Hi Prashant, yes I did.

        Rather than putting equal in the filter, put contains.
        Hope that works.

        1. Prashant Avatar
          Prashant

          Thanks a lot Gaurav..that worked mate!!! 🙂

  7. Megha Avatar
    Megha

    Hi Jitendra, can we achieve the same in Lightning? URL hacking is not possible in Lightning. I want to implement this in lightning as well.

  8. Garima Chaturvedi Avatar
    Garima Chaturvedi

    Hi Jitendra,
    I’m stuck in a similar scenario where in I want to add a filter in a Dashboard that would extract some detail of a parent record. Is it possible?

  9. Missy Avatar
    Missy

    Hi,

    I am not able pass dynamic filters in lightning to rpoerts using fv0 . Can you please help?

  10. Shiva Kumar Avatar
    Shiva Kumar

    Hi All,

    we have a similar requirement using dynamic filtering example : we have fields like brand, division, claim type, factory,start date and end date etc.
    we have implemented form using visual force page and passed parameters through URL (pageReference(‘https://baseURL/lightning/r/Report/ID/view?fv0=’ + memberNameValue + ‘&fv1=’ + memberVCValue +
    ‘&fv2=’ + memberCCValue + ‘&fv3=’ + memberPLValue + ‘&fv4=’ + memberBrandValue+ ‘&fv5=’ + memberDivisionValue+ ‘&fv6=’ + memberLOValue+ ‘&fv7=’ + memberRCValue+ ‘&fv8=’ + memberSCDValue+ ‘&fv9=’ + memberECDValue+ ‘&fv10=’ + memberSSDValue+ ‘&fv11=’ + memberESDValue)

    when user select values and clicks on submit and then redirected to standard report to display selected values.

    in the report filter we are writing AND operator(1 AND 2 AND 3 etc) to generate only selected claims to display.but we are facing the issue report is showing nothing if user select any of the combination.

    Please help me to provide solution, how to write dynamic filter conditions in report or is there any other way to implement.

  11. Aditi Avatar
    Aditi

    Hi,
    When I try to pass the parameter in classic(pv0) and redirect to the report the report does not run by default.
    After redirecting to the report one has to manually click on the run report button.
    Any suggestions?

Leave a Reply to Subrammanian SomasundaraCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading