Forum Discussion

EricMamet's avatar
EricMamet
Helper I
5 years ago

How to dynamically mask data?

In our database, we have a "Secret" boolean flag on each fact row.

 

Whenever I try to report on our data, I cannot return a member as a separate named entity if all the underneath leaf rows are marked with "Secret". In that case, I must group the member value with a real or pretend member "Others".

 

In the screenshot below I show the expected results depending on the queries

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I understand in each request, I would have to invent an "Others" member if it does not exist and assign it the value that are "secret" in this context.

 

Any hint how I could go about doing this?

 

 Thanks

 

PS: Just in case you want to "practice"...

CREATE TABLE dbo.Fact( Colour VARCHAR(100) NOT NULL
, Shape VARCHAR(100) NOT NULL
, Size VARCHAR(100) NOT NULL
, Secret BIT NOT NULL
, Qty INTEGER NOT NULL
, PRIMARY KEY(Colour, Shape, Size)
);
GO

INSERT INTO dbo.Fact(Colour, Shape, Size, Secret, Qty)
VALUES ('Blue', 'Square', 'Big', 0, 1)
,('Green', 'Round', 'Big', 0, 3)
,('Green', 'Square', 'Small', 1, 2)
,('Blue', 'Triangle', 'Big', 0, 5)
,('Red', 'Round', 'Small', 1, 2)
,('Red', 'Square', 'Small', 1, 7)
,('Red', 'Square', 'Big', 0, 4)

 

2 Replies