cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

New Member

Grand Total Incorrect Due to Division

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)

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?

1 ACCEPTED SOLUTION
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
3 REPLIES 3
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
Super User

@domacisaac , Change return like

return

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

New Member

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:

Announcements

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Power BI Monthly Update - February 2024

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

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors