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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Users online (2,009)