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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
zolta_k
Regular Visitor

Summarize - how keep null value

I have data: Data of sales, Product number and Sales Quantity. There are days when there is no sale. For example:

DateNoQuantity
01.04.20231236
03.04.20231239
05.04.20231233
01.04.202398712
02.04.202398713
04.04.202398745

I try to calculate cumulative sum of quantity for last 3 days. It means, for 6 April  it will be period 4 April - 6 April. I try with measure:

Sum of last 3 days =
CALCULATE (
    SUMX( Table1,  Table1[Quantity] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[No] ),
        Table1[Date] <= SELECTEDVALUE( Table1[Date] ) &&
        Table1[Date] >= SELECTEDVALUE( Table1[Date] ) - 3
    )
)

 

It works and i have data for every date even though there are no sales:

DateNoQuantitySum of last 3 days 
01.04.202312366
02.04.2023123 6
03.04.2023123915
04.04.2023123 9
05.04.2023123312
06.04.202312325
01.04.20239871212
02.04.20239871325
03.04.2023987 25
04.04.20239874558
05.04.2023987 45
06.04.2023987 45

 

Now i'd like use summarize function and save this data to new table. 

 

Table2 = SUMMARIZE(
    Table1,
    Table1[Date],
    Table1[No],
    "Sales 3 days", CALCULATE(Sum of last 3 days) 
)
 
and then i lose records with data with no daily sales...
 
DateNoQuantitySum of last 3 days 
01.04.202312366
03.04.2023123915
05.04.2023123312
01.04.20239871212
02.04.20239871325
04.04.20239874558
 
 I'd like to keep all records same as adding a measure to Table1. 
Any ideas?
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @zolta_k 

you need to have a dimDate table connected to the main table then the table dax would be

Table2 =
ADDCOLUMNS (
CROSSJOIN ( VALUES ( 'Date'[Date] ), VALUES ( Table1[No] ) ),
"Sales 3 days", [Sum of last 3 days]
)

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @zolta_k 

you need to have a dimDate table connected to the main table then the table dax would be

Table2 =
ADDCOLUMNS (
CROSSJOIN ( VALUES ( 'Date'[Date] ), VALUES ( Table1[No] ) ),
"Sales 3 days", [Sum of last 3 days]
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.