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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
kristenmcnelly
Frequent Visitor

Measure: Difference between count of deals closed this month and last month

Hello! I am looking to create a measure that calculates the difference between the count of deals closed this month and count of deals closed last month.

 

To get the count of deals, I am getting the distinct count of IDs.

 

I have a completed date field which is the date data type.

 

Thank you very much!

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table with calculated columns formulas for extracting Year, Month name and Month number.  Sort the Month name column by the Month number column.  Create a relationship from the Date column of the Data Table to the Date column of the Calendar Table.  To your Table/matrix visual, drag Year and Month name from the Calendar Table.  Write these measures

Deals closed = distinctcount(Data[ID])

Deals closed in previous month = calculate([Deals closed],previousmonth(Calendar[Date]))

Diff = [Deals closed]-[Deals closed in previous month]

Hope this helps.


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

@kristenmcnelly Maybe:

Measure =
  VAR __Today = TODAY()
  VAR __TMStart = DATE(YEAR(__Today),MONTH(__Today),1)
  VAR __LMEnd = EOMONTH(__Today,-1)
  VAR __LMStart = DATE(YEAR(__LMEnd),MONTH(__LMEnd),1)
  VAR __TM = COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER('Table',[Date] <= __Today && [Date] >= __TMStart),"ID",[ID])))
  VAR __LM = COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER('Table',[Date] <= __LMEnd && [Date] >= __LMStart ),"ID",[ID])))
RETURN
  __TM - __LM

@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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