Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 

 View Only
  • 1.  Blocking a value to create a constant

    Posted Thu May 19, 2022 09:06 AM
    Good afternoon,

    I would like to know how I can create the value of a constant attribute without being affected by the filters.

    For example, I have this attribute that is equal to 4331, but when I use a filter it changes. 



    I want to calculate a rate, and I need this value to be always the same, but without writing its numerical value by hand. That is to say, if one day this value changes, it would be updated, but the filter would still not affect it. I want to create a measure, but I don't know how to do it.

    I don't know if I'm making myself understood

    Best regards,

    ------------------------------
    David GOMEZ PRIETO
    ------------------------------

    #CognosAnalyticswithWatson


  • 2.  RE: Blocking a value to create a constant

    Posted Thu May 19, 2022 01:58 PM

    Hi,

    From the looks of the icon, DUREELOCATION is a measure not an attribute. I would be looking closely at the underlying data to see what values exist in this item on each row. Should every row have the same value? My guess is the values are being aggregated in your report, and therefore when you change the rows returned, the aggregate value is different?

    Cheers!

    MF.



    ------------------------------
    Mark Fry
    Technical Consultant
    ------------------------------



  • 3.  RE: Blocking a value to create a constant

    Posted Fri May 20, 2022 04:33 AM
    Hello,
    Exactly, they are different values that add up. But to make the rate I need that the sum of all of them is always the same to be able to divide and that it does not change according to the filters (but that if new lines are added this maximum changes). It would be like fixing (making a constant) the sum of all values.

    Best regards,

    ------------------------------
    David GOMEZ PRIETO
    ------------------------------



  • 4.  RE: Blocking a value to create a constant
    Best Answer

    Posted Fri May 20, 2022 05:06 AM

    Hi David,

    without knowing your exact data model and your report I can only suggest some general solutions.

    If it's a report, I recommend creating two queries. One for your data incl. filters and another one that only computes the right value for DUREELOCATION. Then join or link those queries together with a real or surrogate key.



    Query "Overall AVG Quantity" holds your average, total min/max or whatever calculated measure value and the key column. Query "data" holds all other necessary data columns and the key column for the join.
    In my sample I get product lines filtered by country and their quantity from "data" and the overall total without any filtering from "Overall AVG Quantity". The result:
    I can filter each country but the overall total for quantity will always be 89,237,091.Another way would be to use induced SQL by writing local SQL directly in one data item of the query but I can only recommend that if you really know what you are doing here.

    If the basic filters of your data query should apply to your fixed value, you can write total([DUREELOCATION] for report). You will get the overall sum for all values visible in the report but with background filters applied.



    ------------------------------
    Robert Dostal
    Team Leader BI
    GEMÜ
    Ingelfingen
    ------------------------------



  • 5.  RE: Blocking a value to create a constant

    Posted Fri May 20, 2022 05:31 AM
    Hi Robert, 
    It was for a dashboard, the total([DUREELOCATION]) seems to work,
    Thank you very much for your help
    Have a good day :)

    ------------------------------
    David GOMEZ PRIETO
    ------------------------------



  • 6.  RE: Blocking a value to create a constant

    Posted Sun May 22, 2022 04:21 AM
    Hello David,

    adding to the solution proposed by Robert:

    total() has options to sum for report or for keys, e.g.
    * total( [VALUECOLUMN] for report) ... would calculated the total for the overall report
    * total( [VALUECOLUMN] for [COUNTRY]) ... would calculate a sum per each COUNTRY and so forth for CURRENCY, COLOR, SIZE, ...   you can also nest them

    Those totals of course get filtered as you described before.

    So, Robert's proposal is the way to go for.

    And glad to see that it worked for you.


    ------------------------------
    Ralf Roeber
    https://linkedin.com/in/ralf-roeber/
    ------------------------------



  • 7.  RE: Blocking a value to create a constant

    Posted Fri May 20, 2022 09:53 AM
    Edited by System Admin Fri January 20, 2023 04:25 PM

    Hi,

    So if you start with (say) 100 rows of data, and the total is (say) 3000 for those hundred rows, obviously the total will change if you start filtering the data set. One way around this would be to add a separate query to your report that totals the rows, and add an item containing a constant to it (eg 'a'). Then add an item with the same constant ('a') to your main query, and join the two queries based on the constant. This way, the total would be available (and would not change) for every row in your main query. You'd probably need to change the aggregation of the item to Maximum so it doesn't double-count in your main query, but this would probably be the way I'd move forward.

    Update - sorry, just saw Robert's post after I submitted this. We could use the old adage "great minds think alike", but in my case I definitely don't qualify for that :-) Kudos to Robert for the detailed reply!

    Cheers!

    MF.



    ------------------------------
    Mark Fry
    Technical Consultant
    ------------------------------