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
BrandonL
Employee
Employee

Need help: % of users who change from True to False based on 2 variables

I have a table in below format and want to find the % of how many players change from value true to false in camera_enabled based on the timestamp and session_id per single player_id.

 

Player_IDSession_IDCamera_enabledTimestamp
1aaaaTrue1:00 PM
1bbbbTrue3:00PM
1bbbbTrue4:00 PM
1aaaaFalse2:00PM
2aaaaTrue1:30 PM
2aaaaFalse2:00 PM
3ccccFalse1:00 PM
3ccccFalse2:00 PM

 

To summarize: 3 unique users... in 3 unique sessions... 1 player paticipated in 2 different sessions... 2 of the 4 pairings have changed state from true to false per player_id per session_id

 

Desired outcome: 50% of the above player_ids per session have changed camera_enabled status from True to False

1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hi @BrandonL 

 

Kindly check below results:

  1. I added a new column to distinct the 4 possibilities.

Column = [Player_ID]&"_"&[Session_ID]

  1. Create the measure to pick the changed items:

Measure = var a = CALCULATE(DISTINCTCOUNT('Table'[Camera_enabled]),ALLEXCEPT('Table','Table'[Player_ID],'Table'[Session_ID],'Table'[Column]))

Return

IF(a>1,1,BLANK())

  1. Final output:

Measure 2 = var a = CALCULATE(DISTINCTCOUNT('Table'[Column]),FILTER('Table',[Measure]<>BLANK()))

var b = DISTINCTCOUNT('Table'[Column])

Return

DIVIDE(a,b)

 

Pbix attached for your ease.

 

Community Support Team _ Dina Ye
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

2 REPLIES 2
v-diye-msft
Community Support
Community Support

Hi @BrandonL 

 

Kindly check below results:

  1. I added a new column to distinct the 4 possibilities.

Column = [Player_ID]&"_"&[Session_ID]

  1. Create the measure to pick the changed items:

Measure = var a = CALCULATE(DISTINCTCOUNT('Table'[Camera_enabled]),ALLEXCEPT('Table','Table'[Player_ID],'Table'[Session_ID],'Table'[Column]))

Return

IF(a>1,1,BLANK())

  1. Final output:

Measure 2 = var a = CALCULATE(DISTINCTCOUNT('Table'[Column]),FILTER('Table',[Measure]<>BLANK()))

var b = DISTINCTCOUNT('Table'[Column])

Return

DIVIDE(a,b)

 

Pbix attached for your ease.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
v-diye-msft
Community Support
Community Support

Hi @BrandonL 

 

Kindly let me know if you'd like to get the below results:

Player1 and Player2 changed value from true to false per session, so the final output should be 2/3=0.67. right?

Measure = var a = CALCULATE(DISTINCTCOUNT('Table'[Camera_enabled]),ALLEXCEPT('Table','Table'[Player_ID],'Table'[Session_ID]))
Return
IF(a>1,1,BLANK())
Measure 2 = var a = CALCULATE(DISTINCTCOUNT('Table'[Player_ID]),FILTER('Table',[Measure]<>BLANK()))
var b = DISTINCTCOUNT('Table'[Player_ID])
Return
DIVIDE(a,b)

 Pbix attached.

 

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

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.