The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello All,
I want to return the number of days in July and I used the measure below measure. It returns 30 days instead of 31 days.
Results
Solved! Go to Solution.
If you meant currently selected month then you can use
Days in current month =
COUNTROWS ( VALUES ( Dates[Date] ) )
or
Days in current month = DISTINCTCOUNT( Dates[Date] )
if you meant in July 2020 then
Days in current month =
COUNTROWS (
FILTER (
Dates,
Dates[Month Number] = MONTH ( TODAY () )
&& Dates[Calendar Year Number] = YEAR ( TODAY () )
)
)
If you meant currently selected month then you can use
Days in current month =
COUNTROWS ( VALUES ( Dates[Date] ) )
or
Days in current month = DISTINCTCOUNT( Dates[Date] )
if you meant in July 2020 then
Days in current month =
COUNTROWS (
FILTER (
Dates,
Dates[Month Number] = MONTH ( TODAY () )
&& Dates[Calendar Year Number] = YEAR ( TODAY () )
)
)
I am looking for a measure that will return the number of days in any current month. July is now the current month so it should return 31 days, Next month is August , when we enter August it shoukd return 31 day as well.
i tried your suggestions, measure number 3 returned blank days. please explain what the year number is suppose to stand for , as i dont have that in my date table.
A snip of my date table below and also the measure below.
thank you
Hi @Selded ,
The above solution looks correct.
However you can try,
Create a Calculated Column in your Date Table.
YearMonthnumber = FORMAT ( Dates[Date],"YYYYM")
Then create a measure
Days in current Month =
VAR _month =
MONTH (
TODAY ()
)
VAR _year =
YEAR (
TODAY ()
)
RETURN
COUNTROWS (
FILTER (
ALL ( Dates ),
Dates[YearMonthnumber]
= CONCATENATE (
_year,
_month
)
)
)
Regards,
Harsh Nathani
Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!
User | Count |
---|---|
24 | |
10 | |
8 | |
7 | |
6 |
User | Count |
---|---|
32 | |
12 | |
10 | |
10 | |
9 |