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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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

 

 



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

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?



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.