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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Ewa_28
Helper II
Helper II

how to calculate accumalated data when data for one of argument doesn't exist.

hello,

I would like to ask for help.

 

I calculated accomulated week (Week Sales - see below). This measure I use for grapth.  

For total country it works - I see accomulated data (picture 1). But when I using filters by regions it dosent't work - becuase data for 2a or 3 (please see attached file) dosen't exist (picture 2). 

 

Week Sales =

 

Var _select_week = MAX('calendar'[week])
VAR _select_kwartal = MAX(calendar'[q])
VAR _select_year = MAX('calendar'[year)
VAR _cur_week = MAX('Sales'[week])
VAR _cur_kwartal = MAX('Sales'[q])
VAR _cur_year = MAX('Sales'[year])

VAR Result =
IF(
    _cur_year = _select_year
    && _cur_kwartal = _select_kwartal
    && _cur_week <= _select_week,

    CALCULATE(
        SUM('Sales'[Sales]),
       'Sales'[week] <= _cur_week,
        'Sales'[q] = _cur_kwartal,
        'Sales'[year] = _cur_year)

)
RETURN
Result
 
picture 1
Ewa_28_0-1723644397017.png

 

 
picture 2
Ewa_28_3-1723644514404.png

 


I will be glad for your help.
8 REPLIES 8
Ewa_28
Helper II
Helper II

Ewa_28
Helper II
Helper II

hi,

 

please see the below my new post.

RRe: how to calculate accumalated data when data fo... - Microsoft Fabric Community

 

please help me

regards, Ewa

Ewa_28
Helper II
Helper II

hi,

 

can you help me, please?

Anonymous
Not applicable

Hi @Ewa_28 ,

 

Can you provide some test data about the data model so that I can answer your question as soon as possible?

 

Best Regards,
Adamk Kong

hi,

I coped data. Please see below. 

YearQWeekRegionArgumentsuma
2024446CEN126
2024450PLN2A160
2024449CEN14
2024450PLD1152
2024446PLD144
2024441PLD118
2024444PLD128
2024447PLD362
2024450PLD2A79
2024447PLD2A20
2024448PLN2B6
2024444PLN2A10
2024447PLN2A9
2024443WSC2A45
2024450CEN17
2024443PLD2A46
2024450PLD2B8
2024443WSC148
2024449WSC120
2024450PLN2B29
2024443PLD124
2024450PLD313
2024449CEN2B20
2024443CEN129
2024440PLD2A40
2024446WSC123
2024443PLN130
2024443PLN2A30
2024445WSC117
2024450PLN136
2024449PLN152
2024440WSC2A22
2024448PLN118
2024445PLN132
2024441WSC2A23
2024450WSC2A42
2024446PLD2A66
2024450WSC2B29
2024446PLN159
2024445CEN127
2024446PLN2A71
2024445PLN2B4
2024440PLD15
2024450WSC110
2024441PLD2a26
2024441PLD2B35
2024449WSC33
2024441WSC12
2024449PLD2A27
2024442PLD13
2024442CEN117
2024443CEN36
2024440CEN120
2024440CEN310
2024441PLD325
2024442WSC342

 

 

and I also coped custom calendar, I use in my report.

YearWeekQDate
202440430.09.2024
202440401.10.2024
202440402.10.2024
202440403.10.2024
202440404.10.2024
202440405.10.2024
202440406.10.2024
202441407.10.2024
202441408.10.2024
202441409.10.2024
202441410.10.2024
202441411.10.2024
202441412.10.2024
202441413.10.2024
202442414.10.2024
202442415.10.2024
202442416.10.2024
202442417.10.2024
202442418.10.2024
202442419.10.2024
202442420.10.2024
202443421.10.2024
202443422.10.2024
202443423.10.2024
202443424.10.2024
202443425.10.2024
202443426.10.2024
202443427.10.2024
202444428.10.2024
202444429.10.2024
202444430.10.2024
202444431.10.2024
202444401.11.2024
202444402.11.2024
202444403.11.2024
202445404.11.2024
202445405.11.2024
202445406.11.2024
202445407.11.2024
202445408.11.2024
202445409.11.2024
202445410.11.2024
202446411.11.2024
202446412.11.2024
202446413.11.2024
202446414.11.2024
202446415.11.2024
202446416.11.2024
202446417.11.2024
202447418.11.2024
202447419.11.2024
202447420.11.2024
202447421.11.2024
202447422.11.2024
202447423.11.2024
202447424.11.2024
202448425.11.2024
202448426.11.2024
202448427.11.2024
202448428.11.2024
202448429.11.2024
202448430.11.2024
202448401.12.2024
202449402.12.2024
202449403.12.2024
202449404.12.2024
202449405.12.2024
202449406.12.2024
202449407.12.2024
202449408.12.2024
202450409.12.2024
202450410.12.2024
202450411.12.2024
202450412.12.2024
202450413.12.2024
202450414.12.2024
202450415.12.2024

hi,

please let me know, how I can attache any file?

 

rajendraongole1
Super User
Super User

Hi @Ewa_28 - Slight adjustment of your measure to handle , when filtering by regions where some weeks have no data, causing gaps in your accumulated week sales calculation. 

 

Week Sales =
VAR _select_week = MAX('calendar'[week])
VAR _select_kwartal = MAX('calendar'[q])
VAR _select_year = MAX('calendar'[year])
VAR _cur_week = MAX('Sales'[week])
VAR _cur_kwartal = MAX('Sales'[q])
VAR _cur_year = MAX('Sales'[year])

VAR AllWeeksInFilter =
CALCULATETABLE(
VALUES('calendar'[week]),
ALLSELECTED('Sales')
)

VAR Result =
IF(
_cur_year = _select_year
&& _cur_kwartal = _select_kwartal
&& _cur_week <= _select_week,
CALCULATE(
SUM('Sales'[Sales]),
'Sales'[week] IN AllWeeksInFilter,
'Sales'[q] = _cur_kwartal,
'Sales'[year] = _cur_year
)
)

RETURN
Result

 

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





hi,

 

I implemented your solution but unfortunatelly it dosen't work 😞 

 

this picture shows data for all regions, it isn't accumulated data

Ewa_28_0-1724060165494.png

and
filter by one of regions: this data is not accumulated and I lost week where is no data 

Ewa_28_1-1724060291671.png

 

please help me!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.