Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello everybody,
I am quite new to Power BI and try to solve a task, that I think should be rather easy, however I cannot fiure it out.
In my tabel are two columns like start_date and end_date. Now I want to apply something like a date slicer to filter the data, preferably slicing monthly periods.
What I want to get is the number of rows in my table, that are "active" during the slicer-period, that is, if the period from start_date to end_date is overlapping with the current month from the date slicer (it might also contain the whole month).
Does someone know how to solve this?
I would very much appreciate any help!
Solved! Go to Solution.
Hi @Anonymous ,
You may create calendar table without creating relationship with your data table, then add the date of calendar table to the slicer visual to filter data.
Calendar= CALENDARAUTO()
Then you can create measure like DAX below.
CountRows=
Var SlicerDate=SELECTEDVALUE(Calendar[Date])
Return
CALCULATE(COUNTROWS('Table'),FILTER(ALLSELECTED('Table'),'Table'[start_date ]<=SlicerDate&&'Table'[end_date]>=SlicerDate))
Best Regards,
Amy
Community Support Team _ Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
You may create calendar table without creating relationship with your data table, then add the date of calendar table to the slicer visual to filter data.
Calendar= CALENDARAUTO()
Then you can create measure like DAX below.
CountRows=
Var SlicerDate=SELECTEDVALUE(Calendar[Date])
Return
CALCULATE(COUNTROWS('Table'),FILTER(ALLSELECTED('Table'),'Table'[start_date ]<=SlicerDate&&'Table'[end_date]>=SlicerDate))
Best Regards,
Amy
Community Support Team _ Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey, assuming you have a column that will tell you if the row is "active" then you just need to create the measure. Check this example:
https://docs.microsoft.com/en-us/power-bi/desktop-tutorial-create-measures#create-a-measure
Regards,
Happy to help!
Hi. First let's go with slicers. If you have two columns "From - To" you can add the StartDate as a individual slicer type "After...". Then add other individual filter with EndDate as type "Before...". There you have your range date filtering with dates.
If you want the count of the rows you need to build a DAX Measure like this:
MeasureCount =
CALCULATE (
COUNTROWS(Table),
Table[Column] = "Active"
)
This new measure field will only show the rows with Active in that column. The value of the dates will change with the slicers filtering this measure too.
Hope this helps,
Happy to help!
Hi @ibarrau , thanks for your reply!
I still don't understand how to obtain this Column, with "Active" entries. Is there a way to create a column in dependent on the slicer date?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
105 | |
88 | |
73 | |
66 |
User | Count |
---|---|
124 | |
113 | |
98 | |
80 | |
72 |