Filter an Olap grid from code

Posted by: abellisomi on 25 March 2020, 1:27 pm EST

  • Posted 25 March 2020, 1:27 pm EST

    Hello, I am trying to filter an Olap grid from code - without having to move the field in the FilterFields section. Is that something possible to achieve?

    I am trying with this and unfortunately it is not working:

    var olap = OlapPage.OlapPanel.OlapEngine;
    var fieldYear = olap.Fields["Year"];

    Thanks a lot
  • Marked as Answer

    Replied 25 March 2020, 3:32 pm EST


    To filter a field data, try the following code:
     // apply value filter to show only a few products
    C1.Olap.C1OlapFilter filter = olap.Fields["Name"].Filter;
    filter.ShowValues = "Chang,Henry,Jeff".Split(',');

    // apply range filter to show only some dates
    filter = olap.Fields["Year"].Filter;
    filter.Condition1.Operator = C1.Olap.ConditionOperator.GreaterThanOrEqualTo;
    filter.Condition1.Parameter = new DateTime(2008, 1, 1);
    filter.Condition2.Operator = C1.Olap.ConditionOperator.LessThanOrEqualTo;
    filter.Condition2.Parameter = new DateTime(207, 12, 31);
    filter.AndConditions = true;
    With best wishes,
  • Replied 25 March 2020, 10:17 pm EST

    Great thanks
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels