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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DearestYoki
Frequent Visitor

How to show comparison between current period vs previous period by month?

Hi all,

 

I am currently working on a chart showin growth of current period (MTD, QTD, YTD, L3M, L6M...) vs previous period by month.

I will use MTD as an example, the expression of growth will look like this:

IF(SELECTEDVALUE(Filter1[Period1])="MTD",
(TOTALMTD(SUMX(FILTER(Raw1,Raw1[Level]="Item"),Raw1[Volume/Value]),'Calendar'[Date])-
CALCULATE(TOTALMTD(SUMX(FILTER(Raw1,Raw1[Level]="Item"),Raw1[Volume/Value]),'Calendar'[Date]),DATEADD('Calendar'[Date],-1,MONTH)))/
CALCULATE(TOTALMTD(SUMX(FILTER(Raw1,Raw1[Level]="Item"),Raw1[Volume/Value]),'Calendar'[Date]),DATEADD('Calendar'[Date],-1,MONTH))
In short, it's calculating (value MTD - value LMTD)/value LMTD
Then I want to show this value by month, the month value should be corresponding to the period I select. (i.e. if I select "MTD", then it should only show the value of latest month; If I select "L6M", it will show 6 months ago till the latest month) So I use Raw1[Month] as the axis instead of the 'Calendar'[Month] in master calendar. 
After I put everything in the chart, the chart becomes empty.
+-Growth MTD vs LMTD+-Growth MTD vs LMTD Tracking dataTracking data
I tracked the data used for this particular visual and the value for "Total" is exactly what I am expecting.
The ideal chart will be showing Sep only with -0.0282 as the bar value.
 
Then for another KPI of difference between current period and previous period, the chart is showing months of both current period and previous period.
The expression for difference between current L3M and prev L3M will be:
IF(SELECTEDVALUE(Filter1[Period1])="L3M",
CALCULATE(SUMX(FILTER(Raw1,Raw1[Level]="Item"&&Raw1[CDESC]="Total Thailand"),Raw1[Volume/Value]),DATESBETWEEN('Calendar'[Date],[L3M Start],[PeriodEnd]))-
CALCULATE(SUMX(FILTER(Raw1,Raw1[Level]="Item"&&Raw1[CDESC]="Total Thailand"),Raw1[Volume/Value]),DATESBETWEEN('Calendar'[Date],[L6M Start],[L3M Start]-1))
L3M current vs L3M previousL3M current vs L3M previousTracking DataTracking Data
The snapshots are for L3M chart and its tracking data.
 
Based on the 2 scenarios above, I would like to ask for help on how to obtain a proper comparison result shown in a proper range of months. 
The ideal chart should be showing JUL - SEP only with some difference...
 
It would be great if anyone could help me. Thanks so much!
 
Best Regards,
Yoki
2 REPLIES 2
v-lionel-msft
Community Support
Community Support

Hi @DearestYoki ,

 

Do you mind sharing your .pbix file? Or show us the sample data.

 

Best regards,
Lionel Chen

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

amitchandak
Super User
Super User

@DearestYoki , TRY a 3 month prior measure for 3-6 Month with same formula L3M

example

3 month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-3,Month))

 

Use this in this measure in formula same as L3M for L3M prior

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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