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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

DAX Weekly Total Sales by Store giving wrong totals

Hi,

 

I have sales data by weekly for each store.

And when I am calculatinng the sales % contributionn of each item at store level by weekly..

MohanV128256_0-1693391760379.png

The measure which i have written is giving right value for each item wise whe calcualte the contribution in % as 

MohanV128256_1-1693391837477.png

But my total sales values at each store and weekly is giving wrong total  here and hence the % values also coming wrong at total.

 

DAX:

_TotalSales = 

CALCULATE(SUM(FFD_ADOPTION_RESULT[SALES_AMT]),
FILTER(ALLSELECTED(FFD_ADOPTION_RESULT),FFD_ADOPTION_RESULT[Store_Name] = MAX(FFD_ADOPTION_RESULT[Store_Name]) && FFD_ADOPTION_RESULT[Week] = MAX(FFD_ADOPTION_RESULT[Week])))

%Sales = DIVIDE(SUM(SAL_AMT),_TotalSales,0)

 

Can anyone please correct my dax here to get the right total values.

 

Thanks,

Mohan V.

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , for such case prefer a date table with Year Week column and week rank 

 

Have these new columns in Date Table, Week Rank is Important in Date/Week Table

Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format


These measures can help
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.