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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
vejas
Helper I
Helper I

Compare Sales

 

Hello , 

 

  I want to compare sales from different periods. This is my table

 

Table.JPG

 

My Calendar Table -  2016-01-01 till 2018-12-31

Measures:
Sales Total = SUM(Sales[Amount])
Sales Previous Year = CALCULATE([Sales Total],SAMEPERIODLASTYEAR('Calendar'[Date]))

Sales Change = [Sales Total]-[Sales Previous Year]
Sales Change % = DIVIDE([Sales Total]-[Sales Previous Year];[Sales Previous Year])

Sales YTD = CALCULATE([Sales Total];DATESYTD('Calendar'[Date]))

I have no any slicers or any additional filters. 

I just want to see comparable periods - green border table without red bordered measures. How measures should be modified ?

 

 

3 REPLIES 3
PaulDBrown
Community Champion
Community Champion

@vejas

 

you need to create the measures wrapped in a CALCULATE function which filters the year and relevant months.. 

 

for example, for your measure sales change, create a new measure as follows:

 

sales change for green selection = CALCULATE ([sales change],

FILTER(‘calendar’, ‘

calendar’ [year] =YEAR(TODAY())-1

|| ‘calendar’[year] = YEAR(TODAY()) && ‘calendar’[month] < MONTH( TODAY())

)

)

 

These will make the filters dinamic. If you want the month and year filters static, just substitute the corresponding DAX code with the relevant years and months (2107, 2018 and March)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






For Sales Change my solution is

 

Sales Change = IF(OR(ISBLANK([Sales Total]);ISBLANK([Sales Previous Year]));BLANK();[Sales Total]-[Sales Previous Year])

PaulDBrown
Community Champion
Community Champion

What I’m saying is that if you use the measure I posted for each of your measures, the table will only display the values you,ve circled in green.

 

EDIT: Actually, that might filter out the previous years values for 2017. Try the following with the measures:

 

<<New Measures>>  = IF(OR(calendar[year]= YEAR(TODAY()) - 1 , calendar[year] = YEAR(TODAY())  && calendar[month] < MONTH(TODAY())),  [<<YOUR OLD MEASURE>>], BLANK())





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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