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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bgiri2430
Frequent Visitor

Need to cut and merge two column data through measure

I have a table where data is present like below :-

| Column A| Column B|
| NUM (R) | VOT [2022 J NUM]
| NUM (R) | VOT [2021 F NUM]
| NUM (P) | VOT [2022 M NUM]
| NUM (P) | VOT [2021 A NUM]

Required output through measure:-

| Column C |
| 2022 J (R) |
| 2022 F (R)|
| 2022 M (P)|
| 2022 A (P)|

Basically need to cut the data and merge the data from column A and column B through measure.
Please assist

  • Required output through measure

    | Column C |
    | 2022 J (R)|
    | 2022 F (R)|
    | 2022 M (P)|
    | 2022 A (P)|

Please help

5 REPLIES 5
rubayatyasmin
Super User
Super User

Hi, @bgiri2430 

 

Use, MID and RIGHT dax functions. for example.

 

see the document https://learn.microsoft.com/en-us/dax/right-function-dax

https://learn.microsoft.com/en-us/dax/mid-function-dax

 

 

Column C =
MID([Column B], 6, 4) & " " &
MID([Column B], 11, 1) & " (" &
RIGHT([Column A], 1) & ")"

 

if you want to use power query, use text.middle and text.end - though it would be a custom column not a measure.

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Thanks for this solution. I have already created through custom column using mid dad function but trying to create through measure. Let me know you have any solutions through measure creation.

dax is mentioned already. 

 

Column C =
MID([Column B], 6, 4) & " " &
MID([Column B], 11, 1) & " (" &
RIGHT([Column A], 1) & ")"

 

you need to adjust the dax. like you need add the table name infront of column name. if you check the documents then you will be more clear. 

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Thanks for this @rubayatyasmin 

Actually the data which I have created through field parameter that is the requirement so that the measure should filter the dimension table. Where I tried to create through measure but dint work.

The task you're trying to achieve is better suited for a calculated column rather than a measure. In DAX, measures are used for aggregation purposes and don't return a value for each row of a table; instead, they return a single value based on the entire data set. On the other hand, calculated columns do return a value for each row of a table, based on the existing columns' data, which is what you need in this scenario.

 

try, 

 

Column C =
LEFT(RIGHT('YourTable'[Column B], LEN('YourTable'[Column B]) - FIND("[", 'YourTable'[Column B])), 5) & " " & "(" & RIGHT('YourTable'[Column A], 1) & ")"

 

if it doesn't work then here is another suggestion, 

Based on my understanding, you want to perform a row-level operation through a DAX measure. DAX measures don't support row-level string manipulations.

Typically, this type of operation would be accomplished using a Calculated Column or during data preprocessing. If these methods aren't suitable, you might use a slicer or filter and use selected values in a measure, but this solution has limitations.

 

rubayatyasmin_0-1689517080227.png

 


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors
Top Kudoed Authors