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
Anonymous
Not applicable

Help counting rows based on previous month date

Hey all,

 

In our Org we report 1 month in arrers. So I need to write a DAX measure that looks for "recorded date" for the previous month.

 

Im not sure what if any functions there are in PBI that evaluates current month? I need something to the effect of...

 

Last month Total = Countrows(This month - 1)

 

Thanks,

J

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try with date table

MTD Sales = CALCULATE(countrows(Sales[Table]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(countrows(Sales[Table]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

View solution in original post

Hi @Jaydpie ,

First, you must create a relationship between the fact table and the date dimension.

Next, create the above measures in the file.

3-1.PNG

Here is my test file for your reference.

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Try with date table

MTD Sales = CALCULATE(countrows(Sales[Table]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(countrows(Sales[Table]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Anonymous
Not applicable

Hey,

 

Not sure where to apply these? I have a date table and my data has a "date claim reported" column.

 

I am a noob to PBI

Hi @Jaydpie ,

First, you must create a relationship between the fact table and the date dimension.

Next, create the above measures in the file.

3-1.PNG

Here is my test file for your reference.

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
Europe Fabric Conference

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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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