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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Mauerwinkel
Regular Visitor

Building the running total of a column

Hello,

 

I want to calculate a running total of a column as a new column and created the following DAX-formula:

 

Einspeisung running total in Index1 =
VAR currValue = SELECTEDVALUE(Solar_1h[Index])
RETURN
IF(HASONEVALUE(Solar_1h[Index]), CALCULATE([Einspeisung]Solar_1h[Index] <= currValueALL(Solar_1h) ), [Einspeisung])
where 
Einspeisung = SUM(Solar_1h[Einspeisung (Wh)])
The tabel I get looks the following (no aggregate in column Einspeisung running total Index1):
Mauerwinkel_0-1664712543114.png

Who has an idea, what the problem is. Thanks, 

Holger

1 ACCEPTED SOLUTION

@Mauerwinkel See PBIX attached below signature:

RT = 
    VAR __Index = [Index]
    VAR __Table = FILTER('Table',[Index]<=__Index)
RETURN
    SUMX(__Table,[Production (Wh)])

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Mauerwinkel
Regular Visitor

@Greg_Deckler   

DateTime Production (Wh) Bezug (Wh) Einspeisung (Wh) Index

01.01.2022 00:00016701
01.01.2022 01:00017902
01.01.2022 02:00015503
01.01.2022 03:00014604
01.01.2022 04:00017305
01.01.2022 05:00015106
01.01.2022 06:00018907
01.01.2022 07:00016008
01.01.2022 08:00015409
01.01.2022 09:00611111310
01.01.2022 10:0022318211
01.01.2022 11:00520136612
01.01.2022 12:00992080913
01.01.2022 13:0012050101514
01.01.2022 14:00688054515
01.01.2022 15:0020935616
01.01.2022 16:0015146017
01.01.2022 17:000188018
01.01.2022 18:000210019

@Mauerwinkel See PBIX attached below signature:

RT = 
    VAR __Index = [Index]
    VAR __Table = FILTER('Table',[Index]<=__Index)
RETURN
    SUMX(__Table,[Production (Wh)])

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thanks for your kind support, it works.

Greg_Deckler
Super User
Super User

@Mauerwinkel Not surprising since you are using CALCULATE. There's a better way: Better Running Total - Microsoft Power BI Community


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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks, now I get this:

Mauerwinkel_0-1664714789474.png

 

@Mauerwinkel Please post a sample of your data as text so that I can mock up a PBIX file for you.


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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.