- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Add Previous QTD-YTD-MTD-Yesterday data
Hello,
I am trying to add new column to compare the data with the previous data based on the filter
the filter contains (QTD-YTD-MTD-Yesterday) options
how I can make the prev - net sales column contain the previous period ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi all,thanks for the quick reply, I'll add more.
Hi @manar_alamri ,
Try this
Measure =
VAR _timeFrame = SELECTEDVALUE('yourtable'[Time Frame])
RETURN
SWITCH(TRUE(),
_timeFrame = "Yesterday",CALCULATE([Net Sales],'FactTable'[Date] = TODAY()-1),
_timeFrame = "MTD",CALCULATE([Net Sales],DATESMTD('FactTable'[Date])),
_timeFrame = "ATD",CALCULATE([Net Sales],DATESQTD('FactTable'[Date])),
_timeFrame = "ytd",CALCULATE([Net Sales],DATESYTD('FactTable'[Date]))
)
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hello @manar_alamri,
You can use the SAMEPERIODLASTYEAR, PARALLELPERIOD, or DATEADD functions to calculate previous period sales based on the selected filter.
Prev_Net_Sales =
VAR _TimeFrame = SELECTEDVALUE('Time Frame'[Time Frame])
RETURN
SWITCH(
TRUE(),
_TimeFrame = "Yesterday", CALCULATE(SUM('Sales'[Net Sales]), DATEADD('Date'[Date], -1, DAY)),
_TimeFrame = "MTD", CALCULATE(SUM('Sales'[Net Sales]), PARALLELPERIOD('Date'[Date], -1, MONTH)),
_TimeFrame = "QTD", CALCULATE(SUM('Sales'[Net Sales]), DATESQTD(PREVIOUSQUARTER('Date'[Date]))),
_TimeFrame = "YTD", CALCULATE(SUM('Sales'[Net Sales]), SAMEPERIODLASTYEAR('Date'[Date])),
BLANK()
)
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Thank you @Sahir_Maharaj , it works. However, when selecting the filter based on the quarterly period, the data doesn't appear. Should we have completed at least three months in the current year for it to match with the previous quarter, or is there another reason?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Is the picture what you are trying to achieve, otherwise im not quite sure what you mean. You want a visual with net sales and compare against (QTD, YTD etc).
I would create measures for that, not extra columns.

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
05-22-2024 06:10 AM | |||
03-26-2024 06:56 AM | |||
Anonymous
| 05-23-2023 12:07 PM | ||
07-23-2024 11:45 PM | |||
06-20-2024 12:24 AM |