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.
I have a column "Days of Month" which is just rows from 1 to 31 and a filter above with the date. I want to filter this column to show me the days of each month based on the filter above. For example if the date is 2/2/2020 i would like to see 28 rows on my column. I tried several solutions but i couldn't achieve this.
Solved! Go to Solution.
Thanks for your response @Anonymous . In that case please make the following changes to your measure that was created in step 3 in my answer above :
last day flag =
var _maxsel = MAX(dim_date[Date])
var _lastday = CALCULATE(MAX(dim_date[Last Day of month]), FILTER(dim_date, dim_date[Date] = _maxsel))
var _days = IF (SELECTEDVALUE('Days of the month'[Days of the month]) > _lastday, 0 ,1)
RETURN
_days
The _maxsel variable captures the max selected value on the slicer, and filters the date table to return the last day of the month associated with that date.
This last day value is then compared against each row in the days of the month table. We set a flag of 1 when the value on the table is less than or equal to the last day value.
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊
Hi @Anonymous ,
Please see solution below ;
1) Load data into Power Query
Create a table with a single column named "Days of the month" that has day values from 1 to 31
2) In your date table, add a new column to calculate last day of the month using DAX.
3) Create a mesaure called "last day flag". Capture the value of the last day of the month based on selected date in the slicer, and use that value to filter the days of the month table.
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊
Hi @rohit_singh thanks for you awnser, the problem here is that in the slicer i have to use a range of dated (between option) instead of list and if i implement the filter in the visual i get an empty table.
Hi @Anonymous ,
This is beacuse this mesaure will not be able to handle multiple values. If you select values from a between slicer, say two dates in different months for instance, such as 22/02/22 and 01/03/22, there will be two values for number of days. Feb has 28 or 29, and March as 31.
Can you confirm that both values in the slicer will be from the same month?
Kind regards,
Rohit
No unfortunately the values is from different month the starting value is always 14/8/2018.
So what is your expected output if two dates from seperate months are selected?
@rohit_singh to filter the col according to last date, the first date will always remain the same sorry if i am not mentioned it before.
Thanks for your response @Anonymous . In that case please make the following changes to your measure that was created in step 3 in my answer above :
last day flag =
var _maxsel = MAX(dim_date[Date])
var _lastday = CALCULATE(MAX(dim_date[Last Day of month]), FILTER(dim_date, dim_date[Date] = _maxsel))
var _days = IF (SELECTEDVALUE('Days of the month'[Days of the month]) > _lastday, 0 ,1)
RETURN
_days
The _maxsel variable captures the max selected value on the slicer, and filters the date table to return the last day of the month associated with that date.
This last day value is then compared against each row in the days of the month table. We set a flag of 1 when the value on the table is less than or equal to the last day value.
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊
Yes this was exactly what i wals looking for. Thanks a lot 🙂
@rohit_singh Hi again, sorry that i reopen the topic but i have a problem. The column days of month is in the same table with the date let's say in the "dim date" table and is the code of each day and when i am trying to implement this kind of solution is not working.
To give you an i idea the table is like this
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 |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |