Forum Discussion
Count rows in the period between dates
- 3 years ago
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
It is for creating a new measure.
Items count from one day before to today: = CALCULATE ( COUNTROWS ( Data ), Data[Type] = "Type1", Data[CreatedDate] >= TODAY () - 1 )
Hi , monicaalves4
According to your description, you want to get the count of items which type = "Type1" and you want to make the calculation dynamic? Like last n days?
Here are the steps you can refer to :
(1)We can create a what-if parameter as a slicer:
(2)Then we can create a measure like this:
Measure =
var _slicer= [Parameter Value]
var _first_day = TODAY()- _slicer+1
var _t = FILTER('Table', 'Table'[Type]="Type1" && 'Table'[CreatedDate]>= _first_day && 'Table'[CreatedDate]<=TODAY())
return
COUNTROWS(_t)
(3)Then we can meet your need , when we select the slicer n, it means we get the count of the items in the last n days:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly