cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thmonte Member
Member

Creating a calculated column/table with filters

So I have a data source that looks similar to this

 

Customer IDLocationType
100AZ
101AZ
102AX
103BX
104BX
105BZ

 

And I am trying to get a distinct count of values based on the location similar to this.

 

LocationDistinct Customers Type ZDistinct Customers Type X
A21
B12

 

I was able to create a calucated table to give me a row of distinct values in Location so I have the starting column but I am having a hard time filling the rest of the columns with the correct data.  Am I going about this the correct way?  And will this data update constantly as the data source gets updated?

2 REPLIES 2
Sean Super Contributor
Super Contributor

Re: Creating a calculated column/table with filters

This what your Measures should look like

Distinct Customers TypeZ =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Customer ID] ),
    FILTER ( 'Table', 'Table'[Type] = "Z" )
)

However if you don't want to build individual Measures for each Type

Create a Matrix - place Location in the Rows, Type in the Columns and drag CustomerID to the Values

right click on CustomerID to change the built-in aggregation to Count(Distinct)

You should get the result you posted above! Smiley Happy

Microsoft v-ljerr-msft
Microsoft

Re: Creating a calculated column/table with filters

Hi @thmonte,


I was able to create a calucated table to give me a row of distinct values in Location so I have the starting column but I am having a hard time filling the rest of the columns with the correct data.  Am I going about this the correct way?  And will this data update constantly as the data source gets updated? 

The data in a calculated column/table will update constantly as the data source gets updated. Because the calculated column/table is computed during the database processing(like a data refresh) and then stored in the model. However, it cannot be affected by user selections on the report.

 

As suggested by Sean above, using a measure or Matrix visual should work in your scenario.Smiley Happy

 

Regards

Helpful resources

Announcements
Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors