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

How do i make a table to move data from the rows into new columns?

I have this table:

mitchemmonkey_1-1663756028614.png

For each TEST name (column 1) there are 2 or 3 different lot numbers (Column 2).

What I really need to do is calculate "CV" x "CV" for each "Control Lot" for every "test", e.g., 

RESULT = CV [for Test K; control Lot 193201] x CV [for test K; control lot193203]

Lot numbers change depending on the test however, and some tests may have 3 or more lot numbers, so calculation for some tests could be (for example):

RESULT = CV [for Test FE; control Lot 193201] x CV [for test FE; control lot193203] x  CV [for Test K; control Lot 193205] 

 

My idea is to move the data row for each "TEST" into sequential columns, e.g.:

TEST (column 1); CV for LOT 193201 (Column 2); CV for LOT 193203 (column 3) and so on, so that i can do the necessary calculations more easily.

Please can someone help me with the instructions to make this new table? I thought about using VLOOKUP option, but the only constant is the TEST names. Control Lots will be variable depending on the test, and will change when new data is uploaded.

There must be a simple solution to anipoulate my data 😊

 

 

3 REPLIES 3
Greg_Deckler
Super User
Super User

@mitchemmonkey I don't think that is a good idea. You could do your first calculation like this given the current way the data is formatted (this is DAX, not M Power Query)

 

RESULT Measure = 
  VAR __CV1 = MAXX(FILTER('Table',[Test] = "K" && [Control Lot] = 193201),[CV])
  VAR __CV2 = MAXX(FILTER('Table',[Test] = "K" && [Control Lot] = 193203),[CV])
RETURN
  __CV1 * __CV2

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg 

Sorry - I'm a complete novice and confused by DAX and power query teminology 😬

The control lot number is highly variable, and test dependent - is there a way to make the caluclation work without having to specifiy the lot number "193201" for example? I have over 200 "TEST" items for which i need to get the calculation to work againist different lot numbers.

 

I figured if i could make a new table with each lot number CV side by side (with one row per TEST), it would be simpler!

@mitchemmonkey Right, so, put your Test column in a slicer visual. Put your Control Lot in another slicer visual where you can multi-select. Then you can create a Card visual and use the following measure:

 

RESULT Measure =
  VAR __Test = MAX('Table'[Test])
  VAR __Lots = DISTINCT('Table'[Control Lot]) 
  VAR __Table = FILTER('Table',[Test] = __Test && [Control Lot] IN __Lots)
RETURN
  PRODUCTX(__Table,[CV])

 

So this would allow you to multiply all of the CV values for the specific Test and Control Lots chosen in the slicers for example. Would need more specifics around all of the types of calculations you need to do in order to provide more specific guidance.

 

I just noticed your table is a calculated table, what does the original data look like?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors
Top Kudoed Authors