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
jochendecraene
Helper IV
Helper IV

Has value based on id

Hi

 

I got a list of caseid's and type of contacts with clients. I need to make the difference between id's where there has been a face to fase contact and the ones without a face to face contact.

 

I added a column in power quer with a simple if statement

 

Knipsel.JPG

 

Now I need to write a dax measure to get the number caseid's with and without a face to face contact.

 

Can someone help me out, point me in the right direction, show me an interesting article on these kind of scenario's?

 

thnx!

2 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@jochendecraene 

The the following two measures:

With_F2F =  
	CALCULATE(
		DISTINCTCOUNT( Table02[caseid] ),
		Table02[Face to face] = "YES"
	)

 

No_F2F =  
	SUMX(
		DISTINCT( Table02[caseid] ),
		CALCULATE( INT(NOT "YES" IN VALUES( Table02[Face to face] )))
	)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

Ok @jochendecraene 
This is a little tricky.

The measures you can use :

1.

Count_face_to_face =
COUNTX(
    CALCULATETABLE('Table','Table'[Type]="face to face"),DISTINCTCOUNT('Table'[Id]))
2. 
Count_others =
VAR t =
    SUMMARIZE('Table','Table'[Id],"face_to_face_count",[Count_face_to_face])
    RETURN
    CALCULATE(DISTINCTCOUNT('Table'[Id]),FILTER(t,ISBLANK([face_to_face_count])))
Result :
Ritaf1983_0-1711800943839.png

 

Pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

8 REPLIES 8
jochendecraene
Helper IV
Helper IV

@Ritaf1983 @Fowmy  thank you both very much! Both solutions are good!

 

I found another solution using power query, by combining all the values per id in 1 colom, add an if statement and than simply calculate bases on the outcome of the if statement.

 

Knipsel.JPG

Is this a good alternative approach?

 

Next questions a need to anwser are:

- how much types of contacts are there per id

- wich combinations of contacts and how many are there in the whole dataset

For the first question I would simply count the words per id

The second one for me is more difficult. I would have to take a step back and remove all doubles and then write if statement for the possible cominations 

Are there any dax solutions for these 2 questions based on the orginal table?

 

 

Hi @jochendecraene 
If you need to analyze data row by row, combining rows as you did, is not a good practice.
About the combinations, it seems like a logic of bucket analysis, please check these links:

https://blog.finance-bi.com/power-bi-basket-analysis/

https://www.daxpatterns.com/basket-analysis/

https://www.youtube.com/watch?v=yzDGvZEtYdQ

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

@Ritaf1983 thank you for your feedback and the links. This is helpfull!

Happy to help 🙂

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Fowmy
Super User
Super User

@jochendecraene 

The the following two measures:

With_F2F =  
	CALCULATE(
		DISTINCTCOUNT( Table02[caseid] ),
		Table02[Face to face] = "YES"
	)

 

No_F2F =  
	SUMX(
		DISTINCT( Table02[caseid] ),
		CALCULATE( INT(NOT "YES" IN VALUES( Table02[Face to face] )))
	)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Ritaf1983
Super User
Super User

Hi @jochendecraene 
You can achieve the desired result even without adding a column.
You can use 3 measures :

1 Face_to_face = calculate(distinctcount('yourtable'[caseid]),'yourtable'[type]="face to face")

2. others_=calculate(distinctcount('yourtable'[caseid]),'yourtable'[type]<>"face to face")

3 Diff = [ Face_to_face]-[others_]

more information about "calculate" function is here:

https://learn.microsoft.com/en-us/dax/calculate-function-dax

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

hi @Ritaf1983 

 

thnx, but that doesn't give me the result I need. Maybe I wasn't clear.

 

What I need is the number cases where there has never been a face to face contact and the ones where there has been one.

 

So the result shoud be:

cases with face to face contact: 5

cases without face to face contact: 2

Ok @jochendecraene 
This is a little tricky.

The measures you can use :

1.

Count_face_to_face =
COUNTX(
    CALCULATETABLE('Table','Table'[Type]="face to face"),DISTINCTCOUNT('Table'[Id]))
2. 
Count_others =
VAR t =
    SUMMARIZE('Table','Table'[Id],"face_to_face_count",[Count_face_to_face])
    RETURN
    CALCULATE(DISTINCTCOUNT('Table'[Id]),FILTER(t,ISBLANK([face_to_face_count])))
Result :
Ritaf1983_0-1711800943839.png

 

Pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

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.