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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
VamshiGoud
Frequent Visitor

how to calculate running total if there is no records for remaining month

Hello Team,

 

I have below data where i need to calcluate running total. i have tried diffrent options , but values are repeating for the months which are not having values.

Ex :  Till july it's getting fine after july there is no data for the months, but value are repeating for rest of the months which i dont want . see output for ur better understanding.  Is there any function to restric if no values for months?

 

Input 

YearMonthValues
2024Apr10
2024May20
2024Jun10
2024Jul5
2024Aug 
2024Sep 
2024Oct 
2024Nov 
2024Dec 
2024Jan 
2024Feb 
2024Mar 

 

 

Output

YearMonthValues
2024Apr10
2024May30
2024Jun40
2024Jul45
2024Aug45
2024Sep45
2024Oct45
2024Nov45
2024Dec45
2024Jan45
2024Feb45
2024Mar45

 

Thanks 

2 ACCEPTED SOLUTIONS
DataNinja777
Super User
Super User

Hi @VamshiGoud ,

 

Using a proper calendar table is a best practice in Power BI for handling time-based calculations, including running totals. A calendar table ensures consistent date handling, proper filtering, and easier DAX calculations for tasks like time intelligence, comparisons, and aggregations.

 

You can write a calendar table by the following dax formula.

Calendar = ADDCOLUMNS(
    CALENDAR(DATE(2024, 1, 1), DATE(2025, 12, 31)), -- Adjust date range as needed
    "Year", YEAR([Date]),
    "Month", FORMAT([Date], "MMM"),
    "Month Number", MONTH([Date])
)

Then create a relationship with your fact table by creating an M query added date column like below:

= Table.AddColumn(#"Changed Type1", "Custom Date", each Date.FromText(Text.PadStart(Text.From([Month]), 2, "0") & "/01/" & Text.From([Year])), type date)

Your data model will look like below:

DataNinja777_0-1731681809980.png

Then you can write a running total dax measure on your fact table.

Running Total = 
CALCULATE(
    SUM('Table'[Values]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year] = MAX('Calendar'[Year]) &&
        'Calendar'[Month Number] <= MAX('Calendar'[Month Number])
    )
)

The resulting output will look like below:

DataNinja777_1-1731681898112.png

I have attached an example pbix file for your reference.

Best regards,

 

View solution in original post

divyed
Super User
Super User

Hello @VamshiGoud ,

 

You can modify your dax to handle blank like below :

 

Running_Total_windows =
//Calculate running total and store in variable
VAR _Res =CALCULATE (
    SUM ( Tab_2[Value] ),
    WINDOW (
        1,
        ABS,
        0,
        REL,
        SUMMARIZE(Tab_2,Tab_2[Name],Tab_2[Value]),
        ORDERBY ( Tab_2[Name])
    )
)
//Return where no blank
RETURN IF(ISBLANK(Tab_2[Value]),BLANK(),_Res)
 
divyed_0-1731682408286.png

 

I hope this helps . Mark this as solution if this helps or give a thumbs up.

 

Cheers

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi, @VamshiGoud 

May I ask if you have gotten this issue resolved? If it is solved, please share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.


If it is not resolved, I hope you will provide the full .pbix file via OneDrive or SharePoint. Please be careful to remove all sensitive information and we will do our best to provide ideas for your issue.

 

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Bibiano_Geraldo
Super User
Super User

Hi @VamshiGoud,

Add the bellow measure to stop comulative when value isBlank:

Measure = 
IF(
    ISBLANK(SUM('Table'[Values])), 
    BLANK(),
    [Your Comulative Measure]
)

 

Now you can use the above measure in your Matrix.

 

I hope this help you, if yes, please give a Kudo and accept as solution.


Thank you

divyed
Super User
Super User

Hello @VamshiGoud ,

 

You can modify your dax to handle blank like below :

 

Running_Total_windows =
//Calculate running total and store in variable
VAR _Res =CALCULATE (
    SUM ( Tab_2[Value] ),
    WINDOW (
        1,
        ABS,
        0,
        REL,
        SUMMARIZE(Tab_2,Tab_2[Name],Tab_2[Value]),
        ORDERBY ( Tab_2[Name])
    )
)
//Return where no blank
RETURN IF(ISBLANK(Tab_2[Value]),BLANK(),_Res)
 
divyed_0-1731682408286.png

 

I hope this helps . Mark this as solution if this helps or give a thumbs up.

 

Cheers

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/

@divyed 

 

Thanks for ur reply. but why cumulative values are repeating from Aug to dec when there is no value. could u pls check

Hello @VamshiGoud ,

 

It should not, please check if dax is correct and month are orderes properly.

You can paste youe dax as well to chekc further.

 

Cheers.

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/
DataNinja777
Super User
Super User

Hi @VamshiGoud ,

 

Using a proper calendar table is a best practice in Power BI for handling time-based calculations, including running totals. A calendar table ensures consistent date handling, proper filtering, and easier DAX calculations for tasks like time intelligence, comparisons, and aggregations.

 

You can write a calendar table by the following dax formula.

Calendar = ADDCOLUMNS(
    CALENDAR(DATE(2024, 1, 1), DATE(2025, 12, 31)), -- Adjust date range as needed
    "Year", YEAR([Date]),
    "Month", FORMAT([Date], "MMM"),
    "Month Number", MONTH([Date])
)

Then create a relationship with your fact table by creating an M query added date column like below:

= Table.AddColumn(#"Changed Type1", "Custom Date", each Date.FromText(Text.PadStart(Text.From([Month]), 2, "0") & "/01/" & Text.From([Year])), type date)

Your data model will look like below:

DataNinja777_0-1731681809980.png

Then you can write a running total dax measure on your fact table.

Running Total = 
CALCULATE(
    SUM('Table'[Values]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Year] = MAX('Calendar'[Year]) &&
        'Calendar'[Month Number] <= MAX('Calendar'[Month Number])
    )
)

The resulting output will look like below:

DataNinja777_1-1731681898112.png

I have attached an example pbix file for your reference.

Best regards,

 

uzuntasgokberk
Super User
Super User

Hello @VamshiGoud ,
Add a new colum which gives only date format.
And after could you please use this measure:
CALCULATE( SUM(Values),FILTER(ALL(DimDate[Date]),DimDate[Date) <=MAX(DimDate[Date])))

Kind Regards,
Gökberk Uzuntaş

📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |

SamWiseOwl
Super User
Super User

Hi @VamshiGoud 

You could change your measure to return a 0 or blank instead.

Hide extra =

if( SUM(table[Values]) = blank(), blank(), [Your measure])

 

If there is no value then don't show the running total.


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors