简体   繁体   中英

Conditional Color formatting in SSAS Cube

I have a star schema with a fact table containing the following:

ID             BIGINT IDENTITY, 
FK_Dimension1  BIGINT, 
FK_Dimension2  BIGINT, 
dataValue      NUMERIC(20, 8), 
classification NVARCHAR(20)

The classification defines the security classification for each dataValue, and can contain either "public" or "confidential".

I've created a degenerate dimension which contains the classification field, and the dataValue resides in the associated measure table.

My requirement is to format the dataValue in any tool that is rendering the data as RED if any value in the aggregation of that field contains an associated classification of "confidential". So for example if in an excel pivot table I was displaying the aggregation of 3 values and one of them was confidential then the value should display as red text.

I have the following MDX query in my cube calculations to handle the formatting:

CALCULATE;

SCOPE
(
  [Measures].[dataValue]
);

If([MyDegenDimension].[Classification].[Confidential]) Then
  Fore_Color(This) = 255
End If;

END SCOPE;

This works great whenever there are values in the dataValue field other than zero. If I drill down in my pivot table to show a single value that happens to be zero then the color formatting does not apply. The business requirement is that any confidential value should be flagged as red, and it's valid that a zero value could be confidential. Note it displays the dataValue as red even if the classification dimension is not used in the pivot table.

Is there any way I can alter my MDX query so that it works for zero values as well? I've posted a similar question a while back on SO here Calculation in SSAS Cube not working for zero data values but never got a complete resolution.

I think your SCOPE statement just needs to be tweaked.

Try this:

CALCULATE;

SCOPE
(
  [MyDegenDimension].[Classification].[Confidential], [Measures].[dataValue]
);

  Fore_Color(This) = 255

END SCOPE;

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