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
mbudmx
New Member

Cumulative Values for missing period in a 2x2 matrix

Hi, I am fairly new to powerbi. 

 

I have the following table - 

date map2 va
01-Jan-24 ca 5
01-Feb-24 ca 10
01-Mar-24 ca 14
01-Jan-24 cl 23
01-Mar-24 cl 21
01-Apr-24 cl 54

 

i want to populate cumulative values for each of the month  as show in the table below

map2 jan feb mar apr
ca 5 15 29 29
cl 23 23 44 98
Total 28 38 73 127

 

However, my current dax query doesn't work when there are missing values - 

 

Cumulative Value =
VAR CurrentDate = MAX('Table5'[date])
VAR CurrentMap2 = MAX('Table5'[map2])

RETURN
CALCULATE(
    SUM('Table5'[va]),
    FILTER(
        ALL('Table5'[date]),
        'Table5'[date] <= CurrentDate
    ),
    'Table5'[map2] = CurrentMap2
)
 
The output is this. Also, the totals are incorrect. 
map2 jan feb mar apr
ca 5 15 29
cl 23 44 98
Total 23 15 44 98

i am unable to get it to work. please help.

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Try this approach

  1. Create a Calendar Table with calculated column formulas of Year, Month name and Month number.  Sort the Month name column by the Month number
  2. Create a relationsh (Many to One and Single) from the Date column of the Fact Table to the Date column of the Calendar Table
  3. To your matrix visual, drag Year and Mont name from the Calendar Table
  4. Write these measures

Total = sum('Table5'[va])

Running total = calculate([Total],datesytd(calendar[date],"31/12"))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Sahir_Maharaj
Super User
Super User

Hello @mbudmx,

 

Can you please try this approach:

 

1. Create a Date Table

DateTable = CALENDAR(MIN('Table5'[date]), MAX('Table5'[date]))

2. Update the DAX formula

Cumulative Value = 
VAR CurrentDate = MAX('DateTable'[Date])
VAR CurrentMap2 = MAX('Table5'[map2])
VAR Result = 
    CALCULATE(
        SUM('Table5'[va]),
        FILTER(
            ALL('DateTable'[Date]), 
            'DateTable'[Date] <= CurrentDate
        ),
        'Table5'[map2] = CurrentMap2
    )

RETURN
IF(
    ISINSCOPE('Table5'[map2]), 
    Result, 
    SUMX(
        SUMMARIZE(
            'Table5',
            'Table5'[map2],
            "CumulativeForMap2", [Cumulative Value]
        ), [CumulativeForMap2]
    )
)

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

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