LoginSignup
1
0

More than 5 years have passed since last update.

Cognosレポートで「その他」のアイテムを作成する方法

Posted at

概要

以下のレポートのイメージで、元々「発注方法」は7種類のアイテムがありますが、数量の上位4個以外をまとめて「その他」として集計して表示する方法です。
001.PNG

実装

DMRモデルである「GO販売(分析)」を使用しています。
リストに「発注方法」と「数量」のデータアイテムを配置しています。
002.PNG

リストのクエリーの中身はこんな感じです。
003.PNG

「発注方法並び替え」のデータアイテムは、発注方法を数量の大きい順に並べ替えています。

order([販売 (分析)].[発注方法].[発注方法].[発注方法のタイプ],[数量],BDESC)

「発注方法」は、リストに登場しているアイテムで、「その他」を実装しているロジックは以下です。
最初の _firstFromSet() の中で、ベスト4を出力しています。
その後の、_remainderSet() の中で、それ以外のメンバーをまとめた「その他」を作っています。

  union(
  _firstFromSet (
     [発注方法並び替え]
    , 4
    , 1
  )
  ,  _remainderSet (
    member(
        currentMeasure - total(currentMeasure within set _firstFromSet([発注方法並び替え],4,1))
      , 'その他'
      , 'その他'
      , hierarchy([発注方法並び替え])
    )
    , [発注方法並び替え]
    , 5
  )
)

参考

Quickie: Top 5 or Top 4 with “Others”
http://cognospaul.com/2017/03/06/quickie-top-5-top-4-others/

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0