-1

I am trying to anonymize data, except for the company that's selected in a filter.

Sample data is below:

Company Name Anonymous Name [Calculated Column]
Coca Cola Company A
Wayne Enterprises Company B
Mr. Freeze's Ice Cream Company C
Riddler's Puzzle Palace Company D
Clark's Bars Company E

This table is linked to another, where the COMPANY NAME has some Dollar amounts in a column.

The idea is that I have a table that shows each company's total dollar amounts. BUT! If I select a company in a Filter, I want all other companies to use the "Anonymous Name".

For example, if I choose "Coca Cola" in my Filter, I want the table to be like below:

Company Name Values
Coca Cola 1234
Company B 2233.39
Company C 12309
Company D 9087
Company E 2928

So far, I've seen that SELECTEDVALUE might be the approach, but I don't quite understand how it would work. I've tried this in my [Calculated Column] in the first table:

AnonCo = var _slicer = SELECTEDVALUE(myTable[Company Name], "Test?")
RETURN _slicer

But (perhaps obviously) that doesn't do anything when I choose a company in the filter.

What formula would I use to "swap out" the company names based on a Filter's selection?

Edit: I've also tried just ISFILTERED(myTable[Company Name]) but it returns FALSE even when I put a slicer with that column.

6
  • it can't be accomplished with calculated columns - they can't respond to filters. You must use measures. stackoverflow.com/questions/70148028/… Commented Nov 25 at 22:36
  • @RADO - Yeah, I've gone down the rabbit hole. So far, I've been successful in determining which value is being filtered for (e.g. Wayne Enterprises), but I can't quite figure out how to like, =IF([company name]==[filteredValue],[Company Name],[Anonymous Name] Commented Nov 25 at 23:51
  • can you describe your data model? Is it just one table, or a star schema? Commented Nov 26 at 5:13
  • @RADO - It's really just a large dataset (maybe 20 columns, 400k+rows). I've added a column to my original data that has the random company name next to the true, so now I'm just trying to find a way to code if the Company Name is being filtered for, keep *that name* but use the random name for all others. Commented Nov 26 at 14:53
  • @RADO - Using a measure, I can't reference the table's row info, so that's where I hit the wall. Commented Nov 26 at 15:05

2 Answers 2

1

you can create a new table

Table 2 = DISTINCT('Table'[Company Name])

Do not create relationships between two tables and use this table to filter

then create a measure

MEASURE =
IF (
    MAX ( 'Table 2'[Company Name] ) = MAX ( 'Table'[Company Name] ),
    MAX ( 'Table'[Company Name] ),
    MAX ( 'Table'[Anonymous Name] )
)

then turn off the wrap text for the company column and change the column width to 0 to manually hide that column

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Ooh! I think this is getting me on my way. The one thing, is if I don't select a company in that slicer, it seems to default to one of them. If I do NOT have one selected, is there a way to show either all "Company A/B/C/D/E" or their Actual names? (not sure which is preferable now, just curious how I'd add in the if nothing selected in filter, return names)
Hm, how can I use this on Charts, etc? It's a relatively robust Dashboard, and I'm hoping to be able to interchange the Anonymized names throughout.
0

for your first question, you can edit the DAX to solve it.

MEASURE =
IF (
    DISTINCTCOUNT ( 'Table 2'[Company Name] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table 2'[Company Name] ), ALL ( 'Table 2' ) ),
    MAX ( 'Table'[Anonymous Name] ),
    IF (
        MAX ( 'Table 2'[Company Name] ) = MAX ( 'Table'[Company Name] ),
        MAX ( 'Table'[Company Name] ),
        MAX ( 'Table'[Anonymous Name] )
    )
)

enter image description here

however, for your second question. So far, I don't have any other better solution for that. Since this is a measure and can't add to x-axis

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.