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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
jschembre
Regular Visitor

Predictive analysis using survey results

I am working with a survey in which each respondent answers multiple times on multiple days.  I'm not sure if my problem would be better solved using a different data model or if it's measures.

 

I have sample data provided - each person mentions their three favorite colors each day.  I need to be able to see all possible colors a person might like if they like x color on x day.  I will need this to go back and forth, too.  If a person liked x color on the last day, what did they like before, etc.

 

I've tried measures and have been working to find an "in" type solution similar to SQL, but so far, when I filter down to a specific color/day combination, it's filtering out all the other possiblities.  It's like I need it to filter back up, but can't get that to work quite right.

 

Here are some screen shots to explan better ("PROVIDED" highlighted yelllow is current format of data before I transform in Power BI):

Expected results (existing table uses (x, x, x) formatExpected results (existing table uses (x, x, x) formatUnpivoted data in Power BIUnpivoted data in Power BI

Name

Colors

Joe

(Red, Yellow)

Joe

(Blue, Purple)

Joe

(Yellow, Red)

Dan

(Red, Blue)

Dan

(Blue, Purple)

Dan

(Green, Red)

Mary

(Yellow, Red)

Mary

(Green, Green)

Mary

(Red, Yellow)

 

 

Name

day

color

Joe

Monday

Red

Joe

Tuesday

Yellow

Joe

Monday

Blue

Joe

Tuesday

Purple

Joe

Monday

Yellow

Joe

Tuesday

Red

Dan

Monday

Red

Dan

Tuesday

Red

Dan

Monday

Blue

Dan

Tuesday

Purple

Dan

Monday

Green

Dan

Tuesday

Red

Mary

Monday

Yellow

Mary

Tuesday

Red

Mary

Monday

Green

Mary

Tuesday

Green

Mary

Monday

Red

Mary

Tuesday

Yellow

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @jschembre ,

 

Create two disconnected tables with the days and the colors then add the following measure:

 

Preidction =
VAR selectedLines =
    FILTER (
        GROUPBY ( ALLSELECTED ( 'Table' ), 'Table'[color], 'Table'[Name], 'Table'[day] ),
        'Table'[day] = SELECTEDVALUE ( 'Weekday'[WeekDay] )
            && 'Table'[color] = SELECTEDVALUE ( 'Color Slicer'[Color] )
    )
VAR Selectpersons =
    SELECTCOLUMNS ( selectedLines, "Persons", 'Table'[Name] )
RETURN
    COUNTROWS ( FILTER ( 'Table', 'Table'[Name] IN Selectpersons ) )

 

Result below and in attach PBIX file.

 

MFelix_0-1636553702963.png

 

MFelix_1-1636553720404.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @jschembre ,

 

Create two disconnected tables with the days and the colors then add the following measure:

 

Preidction =
VAR selectedLines =
    FILTER (
        GROUPBY ( ALLSELECTED ( 'Table' ), 'Table'[color], 'Table'[Name], 'Table'[day] ),
        'Table'[day] = SELECTEDVALUE ( 'Weekday'[WeekDay] )
            && 'Table'[color] = SELECTEDVALUE ( 'Color Slicer'[Color] )
    )
VAR Selectpersons =
    SELECTCOLUMNS ( selectedLines, "Persons", 'Table'[Name] )
RETURN
    COUNTROWS ( FILTER ( 'Table', 'Table'[Name] IN Selectpersons ) )

 

Result below and in attach PBIX file.

 

MFelix_0-1636553702963.png

 

MFelix_1-1636553720404.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank you so much!

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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