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! Request now

Reply
Anon2020
Helper I
Helper I

Cumulative Sales in Two Date Ranges

I have a Calendar Date Table that has the heirarchy in the first three columns. Followed by my 'Opportunity Product' Table that produces the sales. I then have the delivered date in the same table, followed by the Day of Year that is descending (Jan 1st = 366, Dec 31st = 1). I will always be selecting at least two years for my line graph. 

 

I would like to have a cumulative and continuous line chart that records $0 for any day between the first date-column and the closing date. You can see what the sum of total sales looks like in the attached graph. I have tried the quick measure formula as well as 

 

dayRunSum =
CALCULATE(
    SUM('Opportunity Product'[TotalPrice]),
    FILTER(
        ALLSELECTED('Calendar'), [Year] = MIN('Calendar'[Year]) && [posDayNoOfYr] <= MIN('Calendar'[posDayNoOfYr])))
 
which does not work either. Any help would be greatly appreciated!

 

Screenshot 2025-08-14 221417.png

1 ACCEPTED SOLUTION
alish_b
Responsive Resident
Responsive Resident

Hey @Anon2020 ,

 

I am not sure if I understood your problem correctly but could you try adding a zero in the measure formula like follows:

dayRunSum =
CALCULATE(
    SUM('Opportunity Product'[TotalPrice]),
    FILTER(
        ALLSELECTED('Calendar'), [Year] = MIN('Calendar'[Year]) && [posDayNoOfYr] <= MIN('Calendar'[posDayNoOfYr]))) + 0

I am assuming that the value that do show up (in the current screenshot) are correct.

And make sure you have posDayNoOfYr from Calendar Table in the X-axis.

Here we are overriding the Power BI's default feature of returning blanks (when there is no data) by explicitly doing an addition with 0.

Hope it helps and if does not we can break down the requirement further!

View solution in original post

5 REPLIES 5
Anon2020
Helper I
Helper I

You're awesome! It worked! I have never seen anything like that before. What is that doing behind the scenes?

alish_b
Responsive Resident
Responsive Resident

Hey @Anon2020 ,

 

Happy to help!

 

About the behind the hood operation, let's take an example of two tables (a dimension table for Product and a Sales fact table both connected by ProductId):

ProductIdProductName

1

Pro1
2Pro2
3Pro3

And,

ProductIdSalesAmount
120
130
345

When you write a simple measure such as TotalSales = SUM(Sales[SalesAmount]) and then make a table or matrix visual with ProductName from Product table and this SUM measure, it evaluates as below:

ProductNameTotalSales
Pro1SUM of 20 and 30 (i.e. values associated with ProductId 1) = 50
Pro2No values related to Id 2 so it returns a BLANK()
Pro3Sum of just one value = 45

Now, Power BI by default filters out the BLANK() value so in the end you get something like this:

ProductNameTotalSales
Pro150
Pro345

When you explicitly add a zero to the measure with SUM(Sales[SalesAmount]) + 0, your evaluation becomes something like follows:

ProductNameTotalSales
Pro120+30+0 = 50
Pro2BLANK() + 0 = 0
Pro345 + 0 = 45

If you notice this time it is 0 and not BLANK() for the second record, so Power BI will have to show it and you get something like following:

ProductName 
Pro150
Pro20
Pro345

I hope this clarifies things.

If you are interested in studying it in more detail, SQLBI has a detailed article for this: https://www.sqlbi.com/articles/how-to-return-0-instead-of-blank-in-dax/

 

Cheers!

alish_b
Responsive Resident
Responsive Resident

Hey @Anon2020 ,

 

I am not sure if I understood your problem correctly but could you try adding a zero in the measure formula like follows:

dayRunSum =
CALCULATE(
    SUM('Opportunity Product'[TotalPrice]),
    FILTER(
        ALLSELECTED('Calendar'), [Year] = MIN('Calendar'[Year]) && [posDayNoOfYr] <= MIN('Calendar'[posDayNoOfYr]))) + 0

I am assuming that the value that do show up (in the current screenshot) are correct.

And make sure you have posDayNoOfYr from Calendar Table in the X-axis.

Here we are overriding the Power BI's default feature of returning blanks (when there is no data) by explicitly doing an addition with 0.

Hope it helps and if does not we can break down the requirement further!

Now, the only thing is that the summation increases as posDayNoOfYear increases, meaning it is backwards. It should be increasing as the x axis moves towards zero (dec 31st). Any idea how to flip this?

alish_b
Responsive Resident
Responsive Resident

Well I am just going ahead with the blunt requirements as I do not totally understand the context of data but this should flip it:

dayRunSum =
CALCULATE(
    SUM('Opportunity Product'[TotalPrice]),
    FILTER(
        ALLSELECTED('Calendar'),
        'Calendar'[Year] = MIN('Calendar'[Year]) &&
        'Calendar'[posDayNoOfYr] >= MIN('Calendar'[posDayNoOfYr])
    )
) + 0

 

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