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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Div-y-ansh_M
New Member

Total number of services used by a customer.

Hey there, I came across a problem which I'm not sure how to solve.

 

I've 4 Columns i.e., Internet, Phone, TV & CustomerID. In first 3 columns, if a user has opted for it then it's a "yes" else it says "no".

Now, I want to count the total number of services a user has opted for.

 

I'm new to BI & I thought that maybe I'll get some help here.

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

Here is one way to do this:

Data:

ValtteriN_0-1659812848664.png


Dax:

Opted services =
Var C1 = if(MAX(OptedServices[C1])="Yes",1,0)
var c2 = if(MAX(OptedServices[C2])="Yes",1,0)
var c3 = if(MAX(OptedServices[C3])="Yes",1,0)
Return

c1+c2+c3

End result:
ValtteriN_1-1659813103602.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

@Div-y-ansh_M 

This data model is not what PBI likes. Unpivot the 3 columns, so that your table looks like this:

CustomerID | Service  | Value

--------------------------------

1                  | TV          | Yes

1                  | Phone    | No

1                  | Internet | Yes

2                  | TV          | Yes

2                  | Phone    | No

....

 

Once you've got it, then it's dead easy (if you put the CustomerID on rows in a table/matrix visual):

 

[# Services Opted For] =
calculate(
    // You have to decide how you want to
    // calculate this statistic when many
    // CustomerID's are visible in the
    // current context. Here I calculate
    // the number of different services
    // that at least one customer in the
    // current context has opted for.
    distinctcount( T[Service] ),
    keepfilters( T[Value] = "yes" )
)

 

 

ValtteriN
Super User
Super User

Hi,

Here is one way to do this:

Data:

ValtteriN_0-1659812848664.png


Dax:

Opted services =
Var C1 = if(MAX(OptedServices[C1])="Yes",1,0)
var c2 = if(MAX(OptedServices[C2])="Yes",1,0)
var c3 = if(MAX(OptedServices[C3])="Yes",1,0)
Return

c1+c2+c3

End result:
ValtteriN_1-1659813103602.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors