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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MSMKM
Helper I
Helper I

how to achieve running total

Hi Team,

 

i have a table below which i need running table , how we can achieve

first 3 columns we can get from SQL data base and how we can make it output

 

Product

Date

No. of units sold

Output

A

1/1/2023

90

90

A

1/12/2023

100

190

A

1/15/2023

150

340

A

1/4/2023

123

463

B

1/5/2023

300

300

B

1/6/2023

400

700

B

1/7/2023

500

1200

B

1/8/2023

600

1800

C

1/12/2023

60

60

C

1/15/2023

70

130

C

2/11/2023

80

210

C

2/12/2023

90

300

 

 

 

3 REPLIES 3
FreemanZ
Super User
Super User

or you implement with a measure:

Measure = 
VAR CurrentProduct = MAX(TableName[Product])
VAR CurrentDate = MAX(TableName[Date])
RETURN
    SUMX(
        FILTER(
            ALL(TableName),
            TableName[Product]=CurrentProduct
                &&TableName[Date]<=CurrentDate
        ),
        TableName[No. of units sold]
    )

FreemanZ_2-1681306036079.png

FreemanZ
Super User
Super User

hi @MSMKM

try to add a calculated column like:

 

Output2 = 
SUMX(
    FILTER(
        TableName,
        TableName[Product]=EARLIER(TableName[Product])
            &&TableName[Date]<=EARLIER(TableName[Date])
    ),
    TableName[No. of units sold]
)

 

FreemanZ_0-1681305766101.png

 

or 

Output3 = 
VAR CurrentProduct = [Product]
VAR CurrentDate = [Date]
RETURN
    SUMX(
        FILTER(
            TableName,
            TableName[Product]=CurrentProduct
                &&TableName[Date]<=CurrentDate
        ),
        TableName[No. of units sold]
    )

FreemanZ_1-1681305858759.png

 

 

Alf94
Super User
Super User

Hi @MSMKM ,

 

You can create this measure and add it to your visual:

 

 

Running total = 
    SUMX(
        WINDOW(
            1, ABS,
            0, REL,
            ORDERBY(
                'Table'[Product], ASC,
                'Table'[Date], ASC
            )
        ),
        CALCULATE( SUM( 'Table'[No. of units sold] ) )
    )

 

 

I think this can do the trick.

 

Best,

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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