Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Empower Replay: Limited Edition
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
      • About the DevOps Program
      • DataMiner DevOps Support
  • Downloads
  • More
    • DataMiner Releases & Updates
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
      • General Inquiries
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Count row on table LCA

Solved299 views24th October 2024custom-operator LCA
2
Marco Di Blasi200 23rd October 2024 0 Comments

Hi All

In the GQI, I have a table with different alarms, now I need to export from this table the count for each type of severity present in the table.
What I need at the end is table where is present a row for each kind of severity with the count of occurencys, so in this way I can populate in the right way a widget on the LCA.
I tried to build a solution for this with the plain GQI, but it require to create a GQI for each alarm severity type, and also will require to join all the GQI at the end that not work properly on the widget to show the count of the alarms.

I'm tring with the Custom Operator, I'm able to keep track of the occurency for each severity type, but I'm not able to print out the count with the name of the severity as row to any table, how I should achive it?

[GQIMetaData(Name = "DataOperator1")] public sealed class DataOperator1 : IGQIColumnOperator, IGQIRowOperator, IGQIInputArguments
{
        private GQIColumnDropdownArgument _severityColumnArg = new GQIColumnDropdownArgument("Severity") { IsRequired = true, Types = new GQIColumnType[] { GQIColumnType.String } };

        private GQIColumn _severityColumn;
        private GQIStringColumn _severityNameColumnResult = new GQIStringColumn("SeverityType");
        private GQIIntColumn _severityCountColumnResult = new GQIIntColumn("Count");

        public List<Tuple<string, int>> Counters = new List<Tuple<string, int>>();

        public GQIArgument[] GetInputArguments()
        {
            return new GQIArgument[] { _severityColumnArg };
        }

        public OnArgumentsProcessedOutputArgs OnArgumentsProcessed(OnArgumentsProcessedInputArgs args)
        {
            _severityColumn = args.GetArgumentValue(_severityColumnArg);

            return new OnArgumentsProcessedOutputArgs();
        }

        public void HandleColumns(GQIEditableHeader header)
        {
            header.AddColumns(_severityNameColumnResult);
            header.AddColumns(_severityCountColumnResult);
        }

        public void HandleRow(GQIEditableRow row)
        {
            var severityValue = row.GetValue<string>(_severityColumn).ToLower();

            row.SetValue(_severityNameColumnResult, severityValue, $"{severityValue}");
            var index = Counters.FindIndex(t => t.Item1 == severityValue);

            if (index != -1)
            {
                int count = Counters[index].Item2 + 1;
                Counters[index] = Tuple.Create(severityValue, count);
                row.SetValue(_severityCountColumnResult, count, $"{count}");
            }
            else
            {
                Counters.Add(new Tuple<string, int>(severityValue, 1));
                row.SetValue(_severityCountColumnResult, 1, $"{1}");
            }
        }
    }

Here the code I used for the custom operator

Marieke Goethals [SLC] [DevOps Catalyst] Selected answer as best 24th October 2024

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
7
Gilles Bara [SLC] [DevOps Enabler]6.80K Posted 23rd October 2024 2 Comments

You should be able to do this without the need for a custom operator. You can aggregate (distinct count) the alarm ID. This will give you the total amount of alarms, so not exactly what you want. But here comes the interesting part: an aggregation can optionally be followed by one or more group by operators, so aggregate (id) + group by (severity) will give you the total amount of alarms for each severity.

Marieke Goethals [SLC] [DevOps Catalyst] Selected answer as best 24th October 2024
Marco Di Blasi commented 23rd October 2024

Hi Gilles, thanks for your answer, it works like a charms, thanks a lot!

Gilles Bara [SLC] [DevOps Enabler] commented 23rd October 2024

I’m glad it worked out! Just to clarify, a custom operator isn’t the best fit for this use case. Custom operators are typically used to transform one row into another, rather than to produce aggregated results. If the built-in aggregate or group operators weren’t available, you might handle this with an ad-hoc data source, where you have full control over the data and the final output. However, using the built-in operators is faster and generally the preferred approach to achieve the same result.

You are viewing 1 out of 1 answers, click here to view all answers.
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin