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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Pavlous
Advocate II
Advocate II

Showing SUM of values in interval in Matrix

Hey!

 

I have ran into a problem with one of my report.

The demand is to set  "Total to process" things which came from data source (unchangable). I have 3 type of dates here - Received Date, Due Date and End Date. They are connected to calendar table in PBI to make a list of days in a Matrix. The thing is that they are connected by End Date -> Date so values are shown by this preset. If I want to show summary of values coming from lines it will shown only "to process" lines by the end date. I want to show all unprocessed values until the date, including the date. It means that the line was active from for example 1/1/2017 until 5/1/2017 with 5/1/2017 end date. So the sum value takes this line only for 5/1/2017 and I need it to be shown since 1/1/2017 until 5/1/2017 included.

 

I was triing to play with function datesbetween in calculation function with not correct resolutions.

D8CF11C9.PNG

 

 

 

 

Any ideas?

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Pavlous,

 

You can try to use below formula to create the output table:

Summary Table = 
var temp= SELECTCOLUMNS(DISTINCT(UNION(VALUES('Sample'[StartDate]),VALUES('Sample'[EndDate]))),"Date",[StartDate])
return
ADDCOLUMNS(temp,"Total", SUMX(FILTER(ALL('Sample'),'Sample'[StartDate]=[Date]||'Sample'[EndDate]=[Date]),[Count]))

4.PNG

 

Regards,

Xiaoxin Sheng

View solution in original post

Anonymous
Not applicable

@Pavlous,

 

Please check below formula if it suitable for your requirement:

Result=
VAR calendar_date =
    CALENDAR (
        CALCULATE ( FIRSTDATE ( Test[ReceivedDate] ), Test[Categories] = "A" ),
        CALCULATE ( LASTDATE ( Test[EndTime] ), Test[Categories] = "A" )
    )
VAR filted =
    FILTER ( ALL ( Test ), [Categories] = "A" )
RETURN
    ADDCOLUMNS (
        calendar_date,
        "Total", SUMX (
            FILTER (
                ADDCOLUMNS (
                    filted,
                    "Exist", CONTAINS (
                        SELECTCOLUMNS ( CALENDAR ( [ReceivedDate], [EndTime] ), "CheckDate", [Date] ),
                        [CheckDate], [Date]
                    )
                ),
                [Exist] = TRUE ()
            ),
            [To process]
        )
    )

10.PNG

 

Regards,

Xiaoxin Sheng

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @Pavlous,

 

You can try to use below formula to create the output table:

Summary Table = 
var temp= SELECTCOLUMNS(DISTINCT(UNION(VALUES('Sample'[StartDate]),VALUES('Sample'[EndDate]))),"Date",[StartDate])
return
ADDCOLUMNS(temp,"Total", SUMX(FILTER(ALL('Sample'),'Sample'[StartDate]=[Date]||'Sample'[EndDate]=[Date]),[Count]))

4.PNG

 

Regards,

Xiaoxin Sheng

Nice! @Anonymous

Thank you, it is usefull, but can you help me a bit more? How to agregate this code to multi-date difference? If there are more results with differences from start date to end date ( 1, 2, 3, 4...) days?

Anonymous
Not applicable

Hi @Pavlous,


Can you please share some sample data?

 

Regards,

Xiaoxin sheng

Hi @Anonymous

Sure I can, and also lets say that I am interested in only category "A"

09/08/201711/08/2017C3
09/08/201711/08/2017C1
09/08/201711/08/2017C1
09/08/201711/08/2017C1
09/08/201711/08/2017C1
09/08/201711/08/2017C1
09/08/201713/08/2017C1
09/08/201713/08/2017C1
09/08/201713/08/2017C1
09/08/201709/08/2017A21
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A11
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A3
09/08/201710/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201710/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A12
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201710/08/2017A2
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201715/08/2017A25
09/08/201710/08/2017A25
09/08/201712/08/2017A25
09/08/201710/08/2017A25
09/08/201712/08/2017A25
09/08/201714/08/2017B4
Anonymous
Not applicable

@Pavlous,

 

Please check below formula if it suitable for your requirement:

Result=
VAR calendar_date =
    CALENDAR (
        CALCULATE ( FIRSTDATE ( Test[ReceivedDate] ), Test[Categories] = "A" ),
        CALCULATE ( LASTDATE ( Test[EndTime] ), Test[Categories] = "A" )
    )
VAR filted =
    FILTER ( ALL ( Test ), [Categories] = "A" )
RETURN
    ADDCOLUMNS (
        calendar_date,
        "Total", SUMX (
            FILTER (
                ADDCOLUMNS (
                    filted,
                    "Exist", CONTAINS (
                        SELECTCOLUMNS ( CALENDAR ( [ReceivedDate], [EndTime] ), "CheckDate", [Date] ),
                        [CheckDate], [Date]
                    )
                ),
                [Exist] = TRUE ()
            ),
            [To process]
        )
    )

10.PNG

 

Regards,

Xiaoxin Sheng

@Anonymous

Nice!

Thank you man! Working just perfectly!

 

I have to admit, that I am not even close with my knowledge in comparison with you.

Hi @Anonymous

Sure... there they are. I am also interested only in Categories "A"

Received DateEnd TimeCategoriesTo process
09/08/201711/08/2017C3
09/08/201711/08/2017C1
09/08/201711/08/2017C1
09/08/201711/08/2017C1
09/08/201711/08/2017C1
09/08/201711/08/2017C1
09/08/201713/08/2017C1
09/08/201713/08/2017C1
09/08/201713/08/2017C1
09/08/201709/08/2017A21
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A11
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A3
09/08/201710/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201710/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A25
09/08/201711/08/2017A12
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201710/08/2017A2
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201710/08/2017A25
09/08/201715/08/2017A25
09/08/201710/08/2017A25
09/08/201712/08/2017A25
09/08/201710/08/2017A25
09/08/201712/08/2017A25
09/08/201714/08/2017B4

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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