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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
domacisaac
New Member

Grand Total Incorrect Due to Division

domacisaac_1-1649896804632.png
Hi, I have been struggling to ensure that I get an accurate subtotal for this Measure I hae created. In essence, I have to divide the day over day change in expected sales by the number of days remaining in the month. This works accurately for the delivery months but not for the subtotal. I know the issue is that it is pulling an average value, like 24 (shown below) 
domacisaac_2-1649896899498.png
 
Here is my dax:
DTD Daily Sales =
VAR maxdate= SELECTEDVALUE('DIM vDate'[Display Date])
var max2date= SELECTEDVALUE('DIM vDate'[Prev Day])
VAR DailySales_a = CALCULATE(sum('FACT vProfitAndLossMonthly'[Sales]), 'FACT vProfitAndLossMonthly'[Date]= maxdate)
VAR DailySales_b = CALCULATE(sum('FACT vPowerProfitAndLossMonthly'[Sales]),'FACT vPowerProfitAndLossMonthly'[Date] = max2date)
VAR XR = CALCULATE(AVERAGE('FACT vProfitAndLossMonthly'[Date]),'FACT vPowerProfitAndLossMonthly'[Date Diff]= maxdate)
VAR dodchange = CALCULATE(MW_a-MW_b)/XR
return dodchange

 

How do I get this to effectively sum these values instead of dividing the overall change by 24?

 

Thanks in advance

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try this measure

Measure 1 = if(hasonevalue('DIM vDate'[Month name]),[DTD Daily sales],SUMX(VALUES('DIM vDate'[Month name]),[DTD Daily sales]))

Ensure that Year and Month name are dragged from the Calendar Table.

Hope this helps. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Try this measure

Measure 1 = if(hasonevalue('DIM vDate'[Month name]),[DTD Daily sales],SUMX(VALUES('DIM vDate'[Month name]),[DTD Daily sales]))

Ensure that Year and Month name are dragged from the Calendar Table.

Hope this helps. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@domacisaac , Change return like

return

Sumx(Summarize( 'DIM vDate','DIM vDate'[Year],'DIM vDate'[Month], "_1",dodchange), [_1])

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 there, I am getting an error as the year and month that is being displayed is coming from the same table as the sales.
I changed the return statement to:

 

return Sumx(Summarize( 'FACT vProfitAndLossMonthly','FACT vProfitAndLossMonthly'[Delivery Date].[Year],'FACT vProfitAndLossMonthly'[Delivery Date].[Month], "_1",dodchange), [_1])
 
But am unfortunately getting this: 
domacisaac_0-1649906882468.png

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.