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
DTHOMSON198409
New Member

How to Pivot using multiple columns

HI,

 

I am in the middle of creating a dashboard from the below Data 

 

DTHOMSON198409_0-1716550855604.png

 

I have been tasked with providing something along the lines of the below where for each DM_CODE FOR each day and price point they would see the difference in prices between each price source, so the user can determine which price is the best or if they are all the same ?

 

Any help would be appreciated 

DTHOMSON198409_1-1716551621311.png

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DTHOMSON198409 ,

The Table data is shown below:

vzhouwenmsft_0-1716780080223.png

Please follow these steps:

1.Adding indexed columns after grouping with Power Query

vzhouwenmsft_1-1716780267193.png

vzhouwenmsft_2-1716780294695.png

vzhouwenmsft_4-1716780459496.png

2.Delete column 'Count', expand column 'Coustom'

vzhouwenmsft_5-1716780563547.png

vzhouwenmsft_6-1716780599950.png

vzhouwenmsft_8-1716780661072.png

3.Use the following DAX expression to create columns

 

bid_price = 
VAR _a = [DM_CODE]
VAR _b = [price_point]
RETURN CONCATENATEX(FILTER('Table','Table'[DM_CODE] = _a && 'Table'[price_point] = _b),[Custom.bid_price],",")
mid_price = 
VAR _a = [DM_CODE]
VAR _b = [price_point]
RETURN CONCATENATEX(FILTER('Table','Table'[DM_CODE] = _a && 'Table'[price_point] = _b),[Custom.mid_price],",")

 

4.Copy the table data to Excel and reopen it using Power Query. Then click on 'Split Columns'

vzhouwenmsft_9-1716780770772.png

vzhouwenmsft_10-1716780948860.png

vzhouwenmsft_11-1716780992859.png

vzhouwenmsft_12-1716781045657.png

5.Use the following DAX expression to create a measure

 

Difference_price.1_price.2 = 
VAR _a = SELECTEDVALUE('Table'[bid_price.1])
VAR _b = SELECTEDVALUE('Table'[bid_price.2])
RETURN IF(ISBLANK(_a),-1,IF(_a = _b,0,DIVIDE(_a - _b,_b,1)))

 

6.Final output

vzhouwenmsft_14-1716781259755.png

 

 

 

 

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @DTHOMSON198409 ,

The Table data is shown below:

vzhouwenmsft_0-1716780080223.png

Please follow these steps:

1.Adding indexed columns after grouping with Power Query

vzhouwenmsft_1-1716780267193.png

vzhouwenmsft_2-1716780294695.png

vzhouwenmsft_4-1716780459496.png

2.Delete column 'Count', expand column 'Coustom'

vzhouwenmsft_5-1716780563547.png

vzhouwenmsft_6-1716780599950.png

vzhouwenmsft_8-1716780661072.png

3.Use the following DAX expression to create columns

 

bid_price = 
VAR _a = [DM_CODE]
VAR _b = [price_point]
RETURN CONCATENATEX(FILTER('Table','Table'[DM_CODE] = _a && 'Table'[price_point] = _b),[Custom.bid_price],",")
mid_price = 
VAR _a = [DM_CODE]
VAR _b = [price_point]
RETURN CONCATENATEX(FILTER('Table','Table'[DM_CODE] = _a && 'Table'[price_point] = _b),[Custom.mid_price],",")

 

4.Copy the table data to Excel and reopen it using Power Query. Then click on 'Split Columns'

vzhouwenmsft_9-1716780770772.png

vzhouwenmsft_10-1716780948860.png

vzhouwenmsft_11-1716780992859.png

vzhouwenmsft_12-1716781045657.png

5.Use the following DAX expression to create a measure

 

Difference_price.1_price.2 = 
VAR _a = SELECTEDVALUE('Table'[bid_price.1])
VAR _b = SELECTEDVALUE('Table'[bid_price.2])
RETURN IF(ISBLANK(_a),-1,IF(_a = _b,0,DIVIDE(_a - _b,_b,1)))

 

6.Final output

vzhouwenmsft_14-1716781259755.png

 

 

 

 

 

 

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.