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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Faeez
Frequent Visitor

I want to fetch data for last week and last month (week wise and month wise data)

 

I would like to get the data week wise and month wise i already tried slicer and got it but i want to display data only for past week and past month without slicer and using DAX query.

 

To achieve 

 

  • DAX query to get data for last week.
  • DAX query to get data for last month.
  • DAX to get P1 reported due to change

 

 

INC NumberPriority CreatedWorkgroupDescriptionChange 
INC200011-Critical15-12-2024Network L2Network issue 
INC200021-Critical14-12-2024DB L2DB issueCHN-1234
INC200031-Critical13-12-2024Network L2Network issue 
INC200041-Critical15-12-2024DB L2DB issueCHN-1234
INC200051-Critical14-12-2024Network L2Network issue 
INC200061-Critical8/12/2024DB L2DB issue 
INC200071-Critical7/12/2024Network L2Network issue 
INC200081-Critical6/12/2024DB L2DB issueCHN-1234

 

8 REPLIES 8
Kedar_Pande
Super User
Super User

@Faeez 

LastWeekData = 
CALCULATE(
COUNTROWS('Table'),
'Table'[Created] >= TODAY() - WEEKDAY(TODAY(), 2) - 7 &&
'Table'[Created] < TODAY() - WEEKDAY(TODAY(), 2)
)
LastMonthData = 
CALCULATE(
COUNTROWS('Table'),
'Table'[Created] >= EOMONTH(TODAY(), -2) + 1 &&
'Table'[Created] <= EOMONTH(TODAY(), -1)
)
P1DueToChange = 
CALCULATE(
COUNTROWS('Table'),
'Table'[Priority] = "1-Critical" &&
NOT(ISBLANK('Table'[Change]))
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Faeez_0-1734956046885.png

For getting data P1 due to change 

 

the tickets inside the table are by default P1 issues so i want to get a count of P1 which are caused due to change. if you the see the table out of 4 issues there are 2 tickets which are caused due to P1. Hence the output i should is 2 but the DAX which you gave is not filtering the count rather giving the overall count.
could you help?

 

@Faeez 

You can try:

P1DueToChange = 
CALCULATE(
COUNTROWS('Table'),
'Table'[Priority] = "1-Critical",
NOT(ISBLANK('Table'[Change]))
)

count of incident no reported this month ( specific month) - 1 to 31st
week - Monday to Sunday

 

could you help me with this one?

for some reason i am getting the overall count rather than getting the count which was caused by change, also i might need the query to get the data for current month which from calendar 1st to 31st

Anonymous
Not applicable

Hi @Faeez ,

I think you can use New table. on top of that you can apply CALCULATETABLE function.

 

I create a table as you mentioned.

vyilongmsft_0-1734572669032.png

Then I create three new tables and here are their DAX codes.

 

LastWeekData = 
CALCULATETABLE(
    'Table',
    'Table'[Created] >= TODAY() - WEEKDAY(TODAY(), 2) - 6 &&
    'Table'[Created] < TODAY() - WEEKDAY(TODAY(), 2) + 1
)

 

vyilongmsft_1-1734572756691.png

 

LastMonthData = 
CALCULATETABLE(
    'Table',
    'Table'[Created] >= EOMONTH(TODAY(), -1) + 1,
    'Table'[Created] <= EOMONTH(TODAY(), 0)
)

 

vyilongmsft_2-1734572784238.png

 

P1Change = 
CALCULATETABLE(
    'Table',
    'Table'[Priority ] = "1-Critical",
    NOT(ISBLANK('Table'[Change ]))
)

 

vyilongmsft_3-1734572831422.png

 

 

Best Regards

Yilong Zhou

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

lbendlin
Super User
Super User

You will have to define what you mean by "last"  and "week".  What day does your week start?

 

Consider using DATEADD(xxx,-7, DAY)  for the week and DATEADD(xxx,-1,MONTH) for the month.

count of incident no reported this month ( specific month) - 1 to 31st
week - Monday to Sunday

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.