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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply

How to calculate weekly percentage of total sum?

I'd like to Calculate weekly index per item with the formula " sum of total"/"sum of a week". The data table is connected to a date table with week numbers. So each item should have a % of total amount for that item for each week.

 

I have tried this, but with an error "The True/False expression does not specify a column. Each True/False expressions used as a table filter expression must refer to exactly one column." Any suggestions. Thanks for your time.

 

IndexLaunch = 
    VAR Total = 
    CALCULATE( SUM ( Seasonal_Index_Launch_Year[Quantity]), SELECTEDVALUE('Item'[No_] ) )

    VAR WeeklyTotal = 
    CALCULATE( SUM( Seasonal_Index_Launch_Year[Quantity]), FILTER( 'Date', 'Date'[Week Number]))

    VAR Index = 
    DIVIDE(WeeklyTotal, Total )

    RETURN Index

 

balaganeshmohan_1-1663937521695.png

 

 

 

7 REPLIES 7

@lbendlinThanks for the response. Sorry I do not understand what you mean by using variables. I am also attaching my sample data. I'd like to create a measure that calculates what percentage of total sum(only for that No_) that particualr No_ was sold in that week. Sorry I am quite new to PBI and experimenting with things. Would appreciate your help. Thanks!

Planned Shipment DateWeekQuantityNo_
01/01/2017 00:00521A
03/01/2017 00:00152A
09/01/2017 00:0021A
24/11/2017 00:00473A
25/11/2017 00:0047130A
27/11/2017 00:004812A
28/11/2017 00:00483A
29/11/2017 00:00485A
30/11/2017 00:00481A
01/12/2017 00:004846A
04/12/2017 00:004921A
05/12/2017 00:004929A
07/12/2017 00:00490A
08/12/2017 00:00493A
11/12/2017 00:00501A
13/12/2017 00:00502A
15/12/2017 00:00501A
18/12/2017 00:00513A
20/12/2017 00:005132A
28/12/2017 00:005221A
29/12/2017 00:00521A
01/01/2023 00:00523866B
02/01/2023 00:001277B
09/01/2023 00:002131B
12/01/2023 00:00215B
13/01/2023 00:00235B
03/04/2023 00:0014754B
06/04/2023 00:001428B
10/04/2023 00:001514B
14/04/2023 00:0015287B
15/04/2023 00:0015187B
17/04/2023 00:0016304B
25/04/2023 00:00176B
01/05/2023 00:0018937B
02/05/2023 00:0018228B
05/05/2023 00:0018379B
15/05/2023 00:00201257B
01/06/2023 00:00221098B
05/06/2023 00:0023400B
06/06/2023 00:0023143B
07/06/2023 00:00239B
15/06/2023 00:002461B
26/06/2023 00:002639B
01/07/2023 00:002628B
02/07/2023 00:002640B

 

IndexLaunch = 
    VAR WeeklyTotal = CALCULATE( SUM('Table'[Quantity]), ALLEXCEPT('Table','Table'[Week],'Table'[No_]))
    var Total = CALCULATE( SUM('Table'[Quantity]), ALLEXCEPT('Table','Table'[No_]))
    return divide(WeeklyTotal, Total, 0 )

lbendlin_0-1664225952109.png

see attached

Sorry this doesn't seem to work. I ended up everything with 100%

 

balaganeshmohan_0-1664268495090.png

 

 

Please show details of your matrix visual. Same number all over usually indicates a broken data model.

It works when I use ALL instead of ALLEXCEPT. Is this odd?

 

Show the DAX and the matrix field wells.

lbendlin
Super User
Super User

CALCULATE( SUM ( Seasonal_Index_Launch_Year[Quantity]), SELECTEDVALUE('Item'[No_] ) )

Don't use SELECTEDVALUE inside a CALCULATE unless it comes from a disconencted table. Use variables instead.

 

Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...


https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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