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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
digitalau
Frequent Visitor

Power BI Calculating Weekly Sum

I am trying to find Weekly Sum in a table , I have a pretty extensive Date table which uniquely identifies a Week. However, it's not working and I am not able to understand why . 

 

What I want is that _MaxWeeklyImpressions should give Sum of All Weekly Impressions . 

 

The value against Each individual date of W46 2017  should be 43,795 ( 8003+7792+7891+7473+6808+5282)

 

Calculation I am using is : 

 

_MaxWeeklyImpressions = CALCULATE(
SUM(ImpressionShare[Impressions]),
ALLEXCEPT('Date','Date'[FW Week Year])
)
 
 

 

powerbi_Weekly Max.png

Any Idea what I am doing wrong here ? Or how It can be achieved ? 

 

Thanks

 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @digitalau ,

 

To use VALUES function should work.

 

Measure = 
CALCULATE (
    SUM ( 'Table'[values] ),
    FILTER ( ALL ( 'Table' ), 'Table'[date] <= MAX ( 'Table'[date] ) ),
    VALUES ( 'Table'[Wn] ),
    VALUES ( 'Table'[date].[Year] )
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
v-frfei-msft
Community Support
Community Support

Hi @digitalau ,

 

To use VALUES function should work.

 

Measure = 
CALCULATE (
    SUM ( 'Table'[values] ),
    FILTER ( ALL ( 'Table' ), 'Table'[date] <= MAX ( 'Table'[date] ) ),
    VALUES ( 'Table'[Wn] ),
    VALUES ( 'Table'[date].[Year] )
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Hi @digitalau ,

 

First, make sure you are using a Calculated Measure for _MaxWeeklyImpressions.

 

If you already are, then it is probably that ALLEXCEPT is not working  because you are refering to another table.


I would suggest to bring your Week column into the same table as Impressions, as such:


Create new calculated column in ImpressionShare Table:

NEW WEEK COLUMN = LASTNONBLANK( 'Date'[FW Week Year] , 0 )

Then Update your _MaxWeeklyImpressions measure , as such:

_MaxWeeklyImpressions = CALCULATE(
SUM(ImpressionShare[Impressions]),
ALLEXCEPT('ImpressionShare','ImpressionShare'[NEW WEEK COLUMN)
)

Let me know if anything is unclear.
Cheers,
Rob

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Robin, 

 

Thank you for the reply. It is a measure already. 

 

It looks like ALLEXCEPT is not working . 

 

They're coming from different tables  linked together with Date Column. ( 1 to Many  from Date to ImpressionShare)

 

The reason I would not want to bring Impressions to Date table is that I am going to have "Date" connections with 12 tables and for several other columns. 

 

I am trying to understand the logic of why it's not working . 

 

 

There's a 1 to many link between Date and Impression table 

 

 

I tried using the method you mentioned . 

 

1. Created a column in ImpressionShare Table : _Week4Impressions , which gives me a week entry in ImpressionShare column

2. Created _SumWeeklyImpressions :  

_SUMWeeklyImpressions = CALCULATE(
SUM(ImpressionShare[Impressions]),
ALLEXCEPT('ImpressionShare','ImpressionShare'[_Week4Impressions]
)
 
However, now it sums up the whole table . ( no aggregation yet to week level ) 
 

hi in case you need it. this is what I did to get my total per week 

weeklysum = calculate(count(Table1[calls]),ALLEXCEPT(Table1,Table1[Creation Week#]))

ERIC_A_0-1665766309833.png

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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