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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

add 2 measures to get only unique values

hi guys,

 

please i need you assistance, i have been trying to do this for a week now, i dont know if its my logic that is wrong. i have two measures as follows:

 

ActiveUsers = 
VAR s= CALCULATE(DISTINCTCOUNT(allproducts[CustomerId]),allproducts[TradeType] = 1, allproducts[TradeStatus]=0)
return
IF(ISBLANK(s),0,s)

 

 and 

 

 

EquityUsers = CALCULATE(DISTINCTCOUNT(allproducts[CustomerId]),allproducts[AggregatePurchaseValue] > 0)

 

 I would like to add these 2 measures and get the total number of distinct customers from the both of them. 

 

this is a copy of my dataset 

Link to Dataset 

 

thank you

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Please try a measure like

ActiveUsers =
VAR s= CALCULATE(DISTINCTCOUNT(allproducts[CustomerId]),filter(allproducts ,(allproducts[TradeType] = 1 && allproducts[TradeStatus]=0) || allproducts[AggregatePurchaseValue] > 0))
return
IF(ISBLANK(s),0,s)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
AlB
Super User
Super User

Hi @Anonymous 

Do you want the intersect of the union of those two groups of customers?

Total users =
VAR activeUsers_ =
    CALCULATETABLE (
        DISTINCT ( allproducts[CustomerId] ),
        allproducts[TradeType] = 1,
        allproducts[TradeStatus] = 0
    )
VAR equityUsers_ =
    CALCULATETABLE (
        DISTINCT ( allproducts[CustomerId] ),
        allproducts[AggregatePurchaseValue] > 0
    )
RETURN
    COUNTROWS ( INTERSECT ( activeUsers_, equityUsers_ ) )

Use UNION instead of INTERSECT on the last line of code if that's what you need

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Thank you for your reply,

 

I tried both the union and the intersect, and they were not exactly what i wanted.

@amitchandak solution gave me the expected output.

amitchandak
Super User
Super User

@Anonymous , Please try a measure like

ActiveUsers =
VAR s= CALCULATE(DISTINCTCOUNT(allproducts[CustomerId]),filter(allproducts ,(allproducts[TradeType] = 1 && allproducts[TradeStatus]=0) || allproducts[AggregatePurchaseValue] > 0))
return
IF(ISBLANK(s),0,s)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Thank you.

 

This is exactly what i wanted.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.