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
william117
Frequent Visitor

create a new column based on two groups

Hello I need your help, I want to transfer information that is in one column to another but placing the data with others that do have, the idea is to compare them, currently it is all in one column, I have the movement group as move_id and the products as product_id , I find sense that from there I can identify them.

 

I tried this DAX but it doesn't show desired values.

 

CANT PT = MAXX(FILTER(Hoja1,Hoja1[move_id]=
EARLIER(Hoja1[move_id])&&NOT(ISBLANK(Hoja1[out]))),Hoja1[out])

 

urgente.png

 

 

I tried this DAX but it didn't work.

 

CANT PT = MAXX(FILTER(Hoja1,Hoja1[move_id]=
EARLIER(Hoja1[move_id])&&FILTER(Hoja1,Hoja1[name_id])=EARLIER(Hoja1[name_id])&&NOT(ISBLANK(Hoja1[out]))),Hoja1[out])

 

 

 

In this image I show how the table is currently and the expected final result.

 

william117_0-1633125223103.png

 

Thanks for your time

 

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

Hi @william117 

 

Try this measure:

 

Measure =
IF(
    SELECTEDVALUE( 'Table'[out] ) = 0,
    MAXX( FILTER( ALL( 'Table' ), [name_id] = MAX( 'Table'[name_id] ) ), [out] ),
    0
)

 

 

If you want to create a column then via following expression

 

Column =
IF(
    [out] = 0,
    MAXX( FILTER( 'Table', [name_id] = EARLIER( 'Table'[name_id] ) ), [out] ),
    0
)

 

 

The difference between measures and columns is that measures are calculated based on the context of the filter, whereas the results of the new column calculation are calculated and stored immediately. The following article may be of help to you.

Calculated Columns and Measures in DAX

I put my pbix file in the attachment you can reference. Plaese let me know if I misundestood you.

 

 

Best Regards

Community Support Team _ chenwu zhu

 

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-chenwuz-msft
Community Support
Community Support

Hi @william117 

 

Try this measure:

 

Measure =
IF(
    SELECTEDVALUE( 'Table'[out] ) = 0,
    MAXX( FILTER( ALL( 'Table' ), [name_id] = MAX( 'Table'[name_id] ) ), [out] ),
    0
)

 

 

If you want to create a column then via following expression

 

Column =
IF(
    [out] = 0,
    MAXX( FILTER( 'Table', [name_id] = EARLIER( 'Table'[name_id] ) ), [out] ),
    0
)

 

 

The difference between measures and columns is that measures are calculated based on the context of the filter, whereas the results of the new column calculation are calculated and stored immediately. The following article may be of help to you.

Calculated Columns and Measures in DAX

I put my pbix file in the attachment you can reference. Plaese let me know if I misundestood you.

 

 

Best Regards

Community Support Team _ chenwu zhu

 

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

parry2k
Super User
Super User

@william117 the best approach would be to unpivot the data, in transform data -> select all the columns except in and out -> right-click and then unpivot other columns, you will get two columns attribute and value, rename these if you want, close and apply

 

and now create a matrix visual, add columns on the rows, add attribute on column and value on the values which will be sum and you will see everything next to each other.

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.