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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jlanigan
New Member

same period last year but I don't have a measure

I have summary sales data table called Sales

 

jlanigan_0-1714401470967.png

 

I want to create a line chart with one line being the sales each month for 2024 and another one being the sales for same month last year.

 

I have a date table related to [Sales]MonthEnding

 

All the examples I'm finding for doing this are doing a CALCULATE on a total sales measure which calculates the total sales from individual sales lines, but I don't have sales lines to sum up for a measure.

 

What do I need to do?

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@jlanigan Try:

Measure = 
  VAR __Date = MAX('Sales'[MonthEnding])
  VAR __PYDate = EOMONTH( __Date, -12 )
  VAR __Table = FILTER( ALL('Sales'), [MonthEnding] = __PYDate )
  VAR __Result = SUMX( __Table, [Sales] )
RETURN
  __Result

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
jlanigan
New Member

Thanks Greg.

 

I really need to get my head around measures.  I can put together a decent report but i'm doing it all with filters and some calculated columns, almost zero measures.

@jlanigan Try my DAX For Humans YouTube channel: DAX for Humans - YouTube


@ 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!:
The Definitive Guide to Power Query (M)

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

@jlanigan Try:

Measure = 
  VAR __Date = MAX('Sales'[MonthEnding])
  VAR __PYDate = EOMONTH( __Date, -12 )
  VAR __Table = FILTER( ALL('Sales'), [MonthEnding] = __PYDate )
  VAR __Result = SUMX( __Table, [Sales] )
RETURN
  __Result

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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