cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gleb
Helper II
Helper II

Applying 1 row value for all rows.

Table that shows answers for question of a people:

_person.id_question_answer_gender
1gender?malemale
1age?18male
1married?nomale
2gender?femalefemale
2age?36female
2married?yesfemale

So, from 1 question we can now know the gender, but I need to see this person's gender in each row related to this person by his/her id. What's the formula for that? Thanks in advance!

2 ACCEPTED SOLUTIONS

Hi @Gleb ,

Here you go :

rohit_singh_0-1655719807835.png

 

__gender =

CALCULATE(
MAX(Gender[answer_]),
FILTER(
ALLEXCEPT(Gender,Gender[_person.id_]),
Gender[question_] = "gender?"
)
)

 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

View solution in original post

v-zhangti
Community Support
Community Support

Hi, @Gleb 

 

You can try the following methods.

Measure:

Measure =
CALCULATE (
    MAX ( 'Table'[_answer] ),
    FILTER (
        ALL ( 'Table' ),
        [_person.id] = SELECTEDVALUE ( 'Table'[_person.id] )
            && [_question] = "gender?"
    )
)

vzhangti_0-1655948650713.png

Column:

gender =
CALCULATE (
    MAX ( 'Table'[_answer] ),
    FILTER (
        'Table',
        [_person.id] = EARLIER ( 'Table'[_person.id] )
            && [_question] = "gender?"
    )
)

vzhangti_1-1655948727394.png

Does it match the output you expect?

 

Best Regards,

Community Support Team _Charlotte

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

4 REPLIES 4
v-zhangti
Community Support
Community Support

Hi, @Gleb 

 

You can try the following methods.

Measure:

Measure =
CALCULATE (
    MAX ( 'Table'[_answer] ),
    FILTER (
        ALL ( 'Table' ),
        [_person.id] = SELECTEDVALUE ( 'Table'[_person.id] )
            && [_question] = "gender?"
    )
)

vzhangti_0-1655948650713.png

Column:

gender =
CALCULATE (
    MAX ( 'Table'[_answer] ),
    FILTER (
        'Table',
        [_person.id] = EARLIER ( 'Table'[_person.id] )
            && [_question] = "gender?"
    )
)

vzhangti_1-1655948727394.png

Does it match the output you expect?

 

Best Regards,

Community Support Team _Charlotte

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

rohit_singh
Solution Sage
Solution Sage

Hi @Gleb ,


You can do this using Power Query.

In the first step, please add a conditional column as shown below :

rohit_singh_1-1655718111045.png


You will see a new column added with gender values and nulls.

In the next step, click on the _gender column, go to "Transform" --> "Fill" --> ''Down"

rohit_singh_2-1655718201614.png

 

This will give you the result as expected

rohit_singh_3-1655718237329.png

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

 

I can't use edit query for this table, I need a dax code

 

Hi @Gleb ,

Here you go :

rohit_singh_0-1655719807835.png

 

__gender =

CALCULATE(
MAX(Gender[answer_]),
FILTER(
ALLEXCEPT(Gender,Gender[_person.id_]),
Gender[question_] = "gender?"
)
)

 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors