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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
stlcards
New Member

Group By or Summarize Help Needed

Hello to all. I am working on a project in Power Pivot in Excel and am stuck on a DAX formula.  I am wanting to calculate total sales for 52, 13 and 4 at a total for each time period.  Once I get that total, that would be used as the denominator in calculating share.  When I used the total formula in DAX, it gave me one combined number all 3 time periods.  

 

Ideally I want a total for 52 weeks, total for 13 weeks and a total for 4 weeks.

 

This is not weekly data, the data returns from the provider in 52 weeks at the upc level or 13 weeks.  

UPCStore NbrTime PeriodSales TYQty TYSales LYQty LY# of Weeks
3944755588208913wk47.761235.82913
9855634879208913wk77.7160013
7692636085209113wk65.781117.94313
5207018231209113wk00152.323413
951798882.8209113wk0024.21413
2628763792210013wk17.924207.044813
741408755821113wk0027.86713
2375369460211113wk00220.814813
1259242549211113wk208.124470.211513
5296235438211113wk348.6700013
343450897321213wk11.9430013
755896320043324wk006.2714
1053798225443324wk49.810232.96524
1036800256043334wk00734.791594
333291803743334wk298.9963359.48764
780101249143334wk680.46135004
128018619443344wk214.1443413.34834
379101395443344wk9.962004
1177486626100452wk0039.94252
11014660927108752wk39.94299.85552
4830995675253352wk179.76120052
1675391850292052wk0065852
1056444583456552wk0099.85552
602821706.5529952wk64.97100052
435106067264952wk39.94239.94252
2829752037100452wk0062.721452
5951822524100452wk53.922011.96252
5990812459101052wk009.96252
2443077004102952wk0031.36752
4 REPLIES 4
stlcards
New Member

Here is more detail about what I am after, the data below is how I will like my Pivot Table to look.  The numbers in the 52 week total, 13 wk total and 4 week total are all the same currently, they should not be.  The current formula I have calculating the total is adding all 3 time periods together.  

 

  52wk52wk52wk52wk52wk13wk13wk13wk13wk13wk4wk4wk4wk4wk4wk
GT StateSales $ TYSales $ LYSales $ ChgTotalTotal YASales $ TYSales $ LYSales $ ChgTotalTotal YASales $ TYSales $ LYSales $ ChgTotalTotal YA
TOTAL SEGMENTTX$6,331,185$6,179,510$151,674$55,759,688$53,288,792$1,742,108$1,520,819$221,288$55,759,688$53,288,792$591,641$506,511$85,131$55,759,688$53,288,792
TOTAL SEGMENTFL$5,148,103$5,510,617-$362,514$55,759,688$53,288,792$1,352,939$1,278,414$74,525$55,759,688$53,288,792$458,121$449,114$9,007$55,759,688$53,288,792
TOTAL SEGMENTNC$2,042,500$2,035,145$7,355$55,759,688$53,288,792$579,884$491,880$88,005$55,759,688$53,288,792$196,376$158,633$37,742$55,759,688$53,288,792
TOTAL SEGMENTOK$2,041,522$2,130,274-$88,753$55,759,688$53,288,792$541,058$509,551$31,507$55,759,688$53,288,792$182,572$161,435$21,136$55,759,688$53,288,792
TOTAL SEGMENTMO$1,768,492$1,767,647$845$55,759,688$53,288,792$470,601$445,141$25,460$55,759,688$53,288,792$161,004$147,262$13,741$55,759,688$53,288,792
TOTAL SEGMENTVA$1,750,933$1,842,432-$91,499$55,759,688$53,288,792$491,311$413,293$78,018$55,759,688$53,288,792$163,141$128,594$34,547$55,759,688$53,288,792
TOTAL SEGMENTTN$1,612,902$1,845,879-$232,976$55,759,688$53,288,792$525,410$442,894$82,516$55,759,688$53,288,792$183,772$129,811$53,961$55,759,688$53,288,792
TOTAL SEGMENTAL$1,597,105$1,388,551$208,554$55,759,688$53,288,792$483,398$338,295$145,102$55,759,688$53,288,792$172,618$108,195$64,423$55,759,688$53,288,792
TOTAL SEGMENTGA$1,492,008$1,147,550$344,458$55,759,688$53,288,792$438,727$309,279$129,448$55,759,688$53,288,792$151,729$103,218$48,511$55,759,688$53,288,792
TOTAL SEGMENTAR$1,481,271$1,362,224$119,047$55,759,688$53,288,792$402,724$336,832$65,892$55,759,688$53,288,792$136,946$117,133$19,813$55,759,688$53,288,792
TOTAL SEGMENTCA$1,439,303$1,320,190$119,112$55,759,688$53,288,792$382,502$313,354$69,148$55,759,688$53,288,792$124,112$106,257$17,855$55,759,688$53,288,792
TOTAL SEGMENTSC$1,411,227$1,524,789-$113,562$55,759,688$53,288,792$371,153$350,944$20,209$55,759,688$53,288,792$119,551$110,682$8,869$55,759,688$53,288,792
TOTAL SEGMENTLA$1,367,964$1,392,275-$24,312$55,759,688$53,288,792$364,850$344,975$19,874$55,759,688$53,288,792$125,556$106,566$18,990$55,759,688$53,288,792
TOTAL SEGMENTIL$1,073,622$1,058,600$15,022$55,759,688$53,288,792$306,912$270,587$36,325$55,759,688$53,288,792$104,833$90,834$13,999$55,759,688$53,288,792
TOTAL SEGMENTAZ$1,067,681$1,136,144-$68,463$55,759,688$53,288,792$305,973$230,605$75,368$55,759,688$53,288,792$109,876$69,162$40,713$55,759,688$53,288,792
TOTAL SEGMENTWA$1,001,709$1,000,070$1,639$55,759,688$53,288,792$268,503$246,689$21,814$55,759,688$53,288,792$83,574$77,877$5,696$55,759,688$53,288,792
TOTAL SEGMENTOH$956,614$867,180$89,434$55,759,688$53,288,792$265,601$227,632$37,969$55,759,688$53,288,792$89,937$77,127$12,810$55,759,688$53,288,792
TOTAL SEGMENTWI$827,115$786,617$40,499$55,759,688$53,288,792$232,129$192,858$39,271$55,759,688$53,288,792$80,215$64,881$15,335$55,759,688$53,288,792
TOTAL SEGMENTMI$674,287$547,291$126,996$55,759,688$53,288,792$199,236$133,395$65,841$55,759,688$53,288,792$65,889$40,608$25,281$55,759,688$53,288,792
TOTAL SEGMENTOR$638,331$655,572-$17,241$55,759,688$53,288,792$180,916$150,396$30,520$55,759,688$53,288,792$57,704$47,102$10,601$55,759,688$53,288,792
TOTAL SEGMENTID$595,809$610,661-$14,852$55,759,688$53,288,792$172,064$137,881$34,184$55,759,688$53,288,792$56,573$44,949$11,624$55,759,688$53,288,792
TOTAL SEGMENTIN$553,504$588,752-$35,248$55,759,688$53,288,792$144,680$140,320$4,360$55,759,688$53,288,792$50,063$47,741$2,322$55,759,688$53,288,792
TOTAL SEGMENTNE$518,522$508,972$9,550$55,759,688$53,288,792$144,977$133,542$11,435$55,759,688$53,288,792$47,836$46,497$1,340$55,759,688$53,288,792
TOTAL SEGMENTNM$446,760$442,230$4,529$55,759,688$53,288,792$132,108$109,696$22,412$55,759,688$53,288,792$44,474$34,439$10,035$55,759,688$53,288,792
TOTAL SEGMENTMT$404,759$330,416$74,344$55,759,688$53,288,792$118,103$87,171$30,932$55,759,688$53,288,792$37,370$27,428$9,942$55,759,688$53,288,792
TOTAL SEGMENTNV$391,706$414,433-$22,727$55,759,688$53,288,792$106,165$98,729$7,436$55,759,688$53,288,792$35,048$30,092$4,956$55,759,688$53,288,792
TOTAL SEGMENTME$387,954$407,495-$19,541$55,759,688$53,288,792$106,659$91,245$15,414$55,759,688$53,288,792$34,947$27,466$7,481$55,759,688$53,288,792
TOTAL SEGMENTIA$357,861$379,373-$21,513$55,759,688$53,288,792$99,171$92,818$6,353$55,759,688$53,288,792$34,243$32,306$1,937$55,759,688$53,288,792
TOTAL SEGMENTWV$303,972$288,828$15,144$55,759,688$53,288,792$81,410$76,410$5,000$55,759,688$53,288,792$29,581$23,510$6,071$55,759,688$53,288,792
TOTAL SEGMENTSD$284,626$288,478-$3,852$55,759,688$53,288,792$85,435$69,226$16,209$55,759,688$53,288,792$27,571$21,653$5,918$55,759,688$53,288,792
TOTAL SEGMENTAK$135,059$136,260-$1,201$55,759,688$53,288,792$33,901$31,198$2,703$55,759,688$53,288,792$10,258$9,488$770$55,759,688$53,288,792
TOTAL SEGMENTMN$120,708$110,271$10,436$55,759,688$53,288,792$31,816$22,672$9,144$55,759,688$53,288,792$11,213$6,022$5,191$55,759,688$53,288,792
TOTAL SEGMENTKY$104,021$118,423-$14,403$55,759,688$53,288,792$29,426$28,112$1,314$55,759,688$53,288,792$8,829$8,219$610$55,759,688$53,288,792
TOTAL SEGMENTHI$82,577$78,505$4,072$55,759,688$53,288,792$20,460$19,585$875$55,759,688$53,288,792$6,709$6,860-$151$55,759,688$53,288,792
TOTAL SEGMENTND$78,548$78,171$377$55,759,688$53,288,792$24,763$18,750$6,013$55,759,688$53,288,792$7,569$5,773$1,796$55,759,688$53,288,792
TOTAL SEGMENTVT$62,909$33,114$29,795$55,759,688$53,288,792$21,859$8,624$13,234$55,759,688$53,288,792$7,168$2,832$4,336$55,759,688$53,288,792
TOTAL SEGMENTMA$52,482$17,057$35,425$55,759,688$53,288,792$21,457$5,369$16,088$55,759,688$53,288,792$7,646$1,599$6,046$55,759,688$53,288,792
TOTAL SEGMENTDC$37,447$38,503-$1,056$55,759,688$53,288,792$9,943$10,316-$373$55,759,688$53,288,792$3,234$3,599-$365$55,759,688$53,288,792
TOTAL SEGMENTNH$4,546$4,114$432$55,759,688$53,288,792$1,456$1,369$87$55,759,688$53,288,792$629$270$360$55,759,688$53,288,792
TOTAL SEGMENTPA$50$1,523-$1,473$55,759,688$53,288,792$25$1,166-$1,141$55,759,688$53,288,792$0$0$0$55,759,688$53,288,792
TOTAL SEGMENTWY$39$696-$657$55,759,688$53,288,792$39$193-$154$55,759,688$53,288,792$0$0$0$55,759,688$53,288,792
TOTAL SEGMENT Total $40,647,688$40,374,818$272,870$55,759,688$53,288,792$11,291,852$9,732,225$1,559,626$55,759,688$53,288,792$3,820,128$3,181,748$638,380$55,759,688$53,288,792

 

What I am trying to solve for is a $ share number.  I would divide the 52wk Sales  $ TY number for TX, into the 52wk Total Sales number as an example.  The 52wk total sales number should be appoximately $40MM

stlcards
New Member

The Pivot table would look something like this.  Trying to calculate the total $ of each time period, so that I can then take that number, use it as the denominator in a share change equation by state.  

 

TX $ Sales/52 week total $ number

 

StateTY Sales$ Trend$ Share

Share Change

TX222,222+4%14.2%+0.3
MO111,111-3%8%-0.2

@stlcards 

I don't have enough information to build a complete measure formula but I as per my understanding you need to do something like this

SUMX (

VALUES ( 'Table'[Time Period] ),

VAR TotalPeriod = CALCULATE ( SUM ( 'Table'[Sales TY] ) )

RETURN

(Your share change equation)

)

tamerj1
Super User
Super User

Hi @stlcards 

Would you pleasee clarify how would you like your pivot table to look like? Can you advise the expected results for the given sample of data?

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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