简体   繁体   中英

How to get the Percentage using MDX

I want to find the percentage of claims in run time.
I learn that it can be achieved using calculated measure, but I do not know how to do that. Please guide me how to find the percentage of claims((line count/grandtotoal) *100).

在此处输入图片说明

Try something like the following:

WITH 
   MEMBER [Measures].[PercentageOfAll] AS
       [Tmp Claim Dim].[Claimno].CURRENTMEMBER
       /
      ([Tmp Claim Dim].[Claimno].[All])
   ,FORMAT_STRING = 'Percent';
SELECT 
    {[Measures].[Tmp Claim Dim Count],
     [Measures].[PercentageOfAll]} ON 0,
     [Tmp Claim Dim].[Claimno].MEMBERS ON 1 
FROM [ACOE PI];

If you want the above to just apply to the measure [Tmp Claim Dim Count] then you could use tuples with this measure in your new measure:

WITH 
   MEMBER [Measures].[PercentageOfAll_ClaimCnt] AS
      ([Tmp Claim Dim].[Claimno].CURRENTMEMBER, [Measures].[Tmp Claim Dim Count])
       /
      ([Tmp Claim Dim].[Claimno].[All], [Measures].[Tmp Claim Dim Count]) 
   ,FORMAT_STRING = 'Percent';
SELECT 
    {[Measures].[Tmp Claim Dim Count]} ON 0,
     [Tmp Claim Dim].[Claimno].MEMBERS ON 1 
FROM [ACOE PI];

You can adapt and try this :

WITH 
   MEMBER [Measures].[Percentage] AS
   [Measures].[line count]/
   ([Measures].[grandtotoal]), 
   FORMAT_STRING = 'Percent';
SELECT 
{[Measures].[Percentage]} ON COLUMNS, 
FROM [yourcube]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM