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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors