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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Bharathi_99
Helper IV
Helper IV

Dynamic previous month data

Hi ,

I need to create a dynamic previous month showing data in power bi

I have date column in Fact table as "date"
I also have views col as "views" in Fact table

I have type name col in Dim table 

If I select particular month from date filter it must show count(views) for previous month of selected month for the Type= News, Reminders and Good to know in my power bi
For example if I select Sep-2022 it must show Aug - 2022 count of views for Type News, Reminders and Good to know 

It must show count for News , Reminders and Good to Know separately

TypePrev Month Count
News500
Reminders267
Good to know900


Like above table it must show

I have a relationship between dim table and fact table with ID

Please help

Thanks in advance!!!

2 REPLIES 2
Sahir_Maharaj
Super User
Super User

Hello @Bharathi_99,

 

Use the following DAX formula to calculate the count of views for the previous month:

Prev Month Count = 
VAR SelectedMonth = SELECTEDVALUE('Fact table'[date])
VAR PreviousMonth = EDATE(SelectedMonth, -1)
RETURN
CALCULATE(
    COUNT('Fact table'[views]),
    'Fact table'[date] = PreviousMonth,
    'Dim table'[Type] IN {"News", "Reminders", "Good to know"}
)

Let me know if you might need further assistance.


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?
➤ 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
Sahir_Maharaj
Super User
Super User

Hello @Bharathi_99,

 

Use the following DAX formula to calculate the count of views for the previous month:

Prev Month Count = 
VAR SelectedMonth = SELECTEDVALUE('Fact table'[date])
VAR PreviousMonth = EDATE(SelectedMonth, -1)
RETURN
CALCULATE(
    COUNT('Fact table'[views]),
    'Fact table'[date] = PreviousMonth,
    'Dim table'[Type] IN {"News", "Reminders", "Good to know"}
)

Let me know if you might need further assistance.


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?
➤ 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

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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