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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.