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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Swalker
Frequent Visitor

UNPIVOT in Power Pivot for Excel

Hi,

 

I am struggling with developing an unpivot algorithm in Power Pivot for Excel.

 

I am loading Transactional Date/LedgerKey/Amount data via ODBC in PowerPivot for Excel DataModel in table TL and then using an algorithm to convert into RunningTotal Table  RT.  The format of the RT Table is eg:

DateLK1LK2LK3
31/01/22100500
28/02/22100-100
31/03/22200601000

 

In RT i created a column for each RT Ledger and each was named RT-XXXX (eg RT-1000)

For the conversion from TL to RT I used for each column (eg RT-1100) the algorithm:

 

 

var CurrentDate=RTTable[Date]
var CurrentLedger=1100
var FilteredTable = FILTER('TL','TL'[Date]<=CurrentDate && 'TL'[LedgerKey]=CurrentLedger)
return
	CALCULATE(SUM('TL'[Amount]),FilteredTable)

 

 

 I only have to press refresh All and new data is loaded and placed in the RT table.

As a last step before creating a (Balance Sheet) Pivot in Excel (the ultimate objective) i need a separate 'unpivoted' table in the DataModel.   3 columns: Data/LedgerKey/Amount

 

Is this unpivoted table possible with an algorithm ? i have seen a lot of PowerBI /PowerQuery unpivot explanations but i do not understand if this will work in this situation. I have seen some examples with UNION but cannot get this work.

 

Any help is well appreciated

 

Thanks

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@Swalker , First you need to unpivot , then join with date table and then create cumulative like formula below or use windows function

 

Cumm Sales = CALCULATE(SUM(Table[Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])))

Cumm Sales = CALCULATE(SUM(Table[Amount]),filter(allselected(date),date[date] <=max(date[Date])))

 

https://radacad.com/pivot-and-unpivot-with-power-bi

Winow , Offset - https://youtu.be/cN8AO3_vmlY?t=31980

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Dear Amit,

Thanks for your reply.

The issue is that the table is now in the DataModel Power Pivot for Excel as a tab [RTTable] but i cannot figure out how to load this in Power Query inorder to unpivot.  RTTable.GIF

any ideas ?

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.