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
Anonymous
Not applicable

Use DAX or Power Query to create a calculated column

 I have a table called Address as shown below

EalTim_0-1639153888575.png

I want to use power query or dax to create calculated column to achieve AddressStatus (current and previous address) as shown below

EalTim_1-1639153985485.png

How can i achieve this in power query

 

 

1 ACCEPTED SOLUTION

ok so if there is no rule, what is the rule you want  to select the data, just the first one in sequential order? 

 

I would add an index in the transformation layer (power query), under add column / index column

 

vanessafvg_0-1639223334624.png

 

and then create a dax measure

 

addressstatus =
VAR person =
    SELECTEDVALUE ( 'table'[fullname] )
VAR currindex =
    SELECTEDVALUE ( 'table'[idcolumn] )
VAR minid =
    CALCULATE ( min ( 'table'[idcolumn] ), 'table'[fullname] = person )
VAR status =
    IF ( currenindex = minid"Current Address""PreviousAddress" )
RETURN
    status





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

Did vanessafvg 's suggestions help with your scenario? if that is the case, you can consider Kudo or accept his suggestions to help others who faced similar requirements.

If that also doesn't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
vanessafvg
Super User
Super User

how do you know which is which?  is there a date column, or is it the first in line?

 

if first inline you can create a index column to extract the data out, if you can provide the data in text format, not a picture that would be good and i can demonstrate.  easier with data.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

@vanessafvg - There is no date with the table. All the records was parsed on JSON and expanded address resulted to the table above. When i look at the json structure, the first is the current address. 

az38
Community Champion
Community Champion

Hi @Anonymous 

what is the rule to define the current address? any indexes or dates or smth else?


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38 - there is no rule that define current address. The table was parsed on JSON, no index, no date. 

ok so if there is no rule, what is the rule you want  to select the data, just the first one in sequential order? 

 

I would add an index in the transformation layer (power query), under add column / index column

 

vanessafvg_0-1639223334624.png

 

and then create a dax measure

 

addressstatus =
VAR person =
    SELECTEDVALUE ( 'table'[fullname] )
VAR currindex =
    SELECTEDVALUE ( 'table'[idcolumn] )
VAR minid =
    CALCULATE ( min ( 'table'[idcolumn] ), 'table'[fullname] = person )
VAR status =
    IF ( currenindex = minid"Current Address""PreviousAddress" )
RETURN
    status





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

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.