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

Helper I

## Calculate Monthly Difference DAX

Hello Power Users,

I'm trying to create a measure or calculation for Monthly difference. but not getting exactly what i need. Basically what i'm trying to do get the difference for Amount for each Milestone number & Date.

I have create a previous month measure like calculate (Sum(Amount), Prevousmonth(Date) that gives me the previous month amount and i'm just subtracting amount-previousmonth amount to the difference. If you observe in the data there is no data for march for 123 in that i would like get the difference Feb to Apr. it should be like 200-400 but in my logic there is no data  for march then it considers as 0 then its give me 200-0.

1 ACCEPTED SOLUTION
Community Support

Hi, @corpsikumar

You can try the following methods.

``````Preamount =
VAR PreDate =
MAXX (
FILTER (
ALL ( 'Table'[Entry_Date], 'Table'[Milestonenumber] ),
[Entry_Date] < SELECTEDVALUE ( 'Table'[Entry_Date] )
&& [Milestonenumber] = SELECTEDVALUE ( 'Table'[Milestonenumber] )
),
'Table'[Entry_Date]
)
VAR Preamount =
CALCULATE (
SUM ( 'Table'[amount] ),
FILTER (
ALL ( 'Table' ),
[Entry_Date] = PreDate
&& [Milestonenumber] = SELECTEDVALUE ( 'Table'[Milestonenumber] )
)
)
RETURN
Preamount
``````
``Difference = IF([Preamount]<>BLANK(),[Preamount]-SUM('Table'[amount]))``

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 REPLIES 2
Community Support

Hi, @corpsikumar

You can try the following methods.

``````Preamount =
VAR PreDate =
MAXX (
FILTER (
ALL ( 'Table'[Entry_Date], 'Table'[Milestonenumber] ),
[Entry_Date] < SELECTEDVALUE ( 'Table'[Entry_Date] )
&& [Milestonenumber] = SELECTEDVALUE ( 'Table'[Milestonenumber] )
),
'Table'[Entry_Date]
)
VAR Preamount =
CALCULATE (
SUM ( 'Table'[amount] ),
FILTER (
ALL ( 'Table' ),
[Entry_Date] = PreDate
&& [Milestonenumber] = SELECTEDVALUE ( 'Table'[Milestonenumber] )
)
)
RETURN
Preamount
``````
``Difference = IF([Preamount]<>BLANK(),[Preamount]-SUM('Table'[amount]))``

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helper I

Thank you so much

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