Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
giorgiokatr
Helper V
Helper V

distinct count with expressions evaluate in selected period

hi there

dateCustomer_idproduct a Purchased timesproduct b Purchased timesYearMonth
31/1/201511400090120151
28/2/201511400090120152
31/3/201511400090120153
30/4/201511400090220154
31/5/201511400091220155
30/6/201511400090220156
31/7/201511400090220157
31/8/201511400090120158
30/9/201511400090120159
31/10/2015114000911201510
30/11/2015114000901201511
31/12/2015114000901201512

 

i would like to distinct count the Customers when product b Purchased but product a did non Purchased

i used

product b Purchased only= CALCULATE(DISTINCTCOUNT(table[Customer_id]);table[product b Purchased times]>0;table[product a Purchased times]=0) 

it works great when i select one month 

for example if i select 2015-1 i have a 1 

if i select 2015-10 i have a null

is it possible when i select for example in my filters all 2015  and months to have distinct count null 

because i would like to show the customers byued product b but not  a in the selected year and this should be in this specific table none.

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @giorgiokatr,

 

Please refer to below measures:

Measure peuchase a =
CALCULATE (
    SUM ( 'table'[product a Purchased times] ),
    ALLSELECTED ( 'table'[date] )
)

Measure purchase b =
CALCULATE (
    SUM ( 'table'[product b Purchased times] ),
    ALLSELECTED ( 'table'[date] )
)

product b Purchased only =
CALCULATE (
    DISTINCTCOUNT ( 'table'[Customer_id] ),
    FILTER (
        SUMMARIZE (
            'table',
            'table'[Customer_id],
            "a", SUM ( 'table'[product a Purchased times] )
        ),
        [Measure purchase b] > 0
            && [Measure peuchase a] = 0
    )
)

1.PNG

 

Also, I have uploaded my .pbix file for your reference.

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @giorgiokatr,

 

Please refer to below measures:

Measure peuchase a =
CALCULATE (
    SUM ( 'table'[product a Purchased times] ),
    ALLSELECTED ( 'table'[date] )
)

Measure purchase b =
CALCULATE (
    SUM ( 'table'[product b Purchased times] ),
    ALLSELECTED ( 'table'[date] )
)

product b Purchased only =
CALCULATE (
    DISTINCTCOUNT ( 'table'[Customer_id] ),
    FILTER (
        SUMMARIZE (
            'table',
            'table'[Customer_id],
            "a", SUM ( 'table'[product a Purchased times] )
        ),
        [Measure purchase b] > 0
            && [Measure peuchase a] = 0
    )
)

1.PNG

 

Also, I have uploaded my .pbix file for your reference.

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks it works perfect! Just a question

you filter a summarize table with the two criteria 

why it works when you use in filter the measures Measure peuchase a  and  Measure peuchase b and dont just use SUM ( 'table'[product a Purchased times] ?

what is the purpose of allselected?

Hi @giorgiokatr,

 

The most difference between measures [Measure peuchase a], [Measure peuchase b] and SUM ( 'table'[product a Purchased times]) is the context. You could add [Measure peuchase a] and  [Measure peuchase b] into table visual, compare their values with SUM ( 'table'[product a Purchased times]) in each row.

 

Here is a blog for your reference to better understand ALLSELECTED.

 

Regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.