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
tradeexllc
Regular Visitor

Incorrect totals when using % calculations with quantity and filters

Hello,

 

I am trying to calculate PY Sales variance and each time I bring in the calculation for PY the totals do not add up. Here are all my formulas in order:

 

QTY PY =
IF (
ISCROSSFILTERED( Sheet1[INVOICE DATE].[Year]),
CALCULATE( sum(Sheet1[QTY SOLD]),
DATEADD('Sheet1'[INVOICE DATE].[Date], -1, YEAR)),
BLANK())
 
PY Total List Price =
IF (
ISCROSSFILTERED( Sheet1[INVOICE DATE].[Year]),
CALCULATE( sum(Sheet1[TOTAL LIST PRICE]),
DATEADD('Sheet1'[INVOICE DATE].[Date], -1, YEAR)),
BLANK())
 
PY Discount $ = sum(Sheet1[NET SALES])-[PY Total List Price]
PY Avg List Price/Ut = [PY Total List Price]/sum(Sheet1[QTY SOLD])
PY Discount % = ([PY Discount $]/[PY Total List Price])
Sales Discount Var PY = (sum(Sheet1[QTY SOLD])*[PY Discount %]) - this gives me incorrect totals. If I change PY Total List Price and PY QTY and remove filter dateadd, the totals will be correct. 
How to change the calculatiosn to give me the right totals?
Thank you!
 

 

3 REPLIES 3
Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

Multiplication should happen at line level or some group level.

So we we do Sum(A*B) Not sum(a)* sum(b)

Do do this is to take a row context

sumx(summarize(table,table[Date],"_sum",sum(Sheet1[QTY SOLD]),"_dis",[PY Discount %]),[_sum]*[_dis])

table[date] is the row context where calculation need to done, it can be id or month as per need

 

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

Hi,

I tried your advise and used the following calcualtions:

 

test = sumx(summarize(Sheet1,Sheet1[INVOICE DATE].[Date],"_sum",sum(Sheet1[QTY SOLD]),"_dis",[PY Discount %]),[_sum]*[_dis])
 
but the result was infinity
 
sample_PBI.png
 
Am I doing something wrong with calculations?
Thank you

 

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.

Jan NL Carousel

Fabric Community Update - January 2025

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