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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Krishna090
New Member

How to get previous months all days and current month today

Hi Team, can someone tell me how to get below one.

with  below code, I'm getting all the days.

Days in month = IF(DATEDIFF(DAY(TODAY())=DATE(YEAR(today()), MONTH(today()), 1),NOW(),Day),DATEDIFF([First date of month],R_AMHS_HLY_UPTIME_DET_VW[Last date of month],DAY)+1)

but I need to get current month current day and previous months all days
req.JPG
 Updating Media

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Krishna090 ;

You could try it.

Days in month =
IF (
    EOMONTH ( [First date of month], 0 ) <> EOMONTH ( TODAY (), 0 ),
    DATEDIFF (
        [First date of month],
        R_AMHS_HLY_UPTIME_DET_VW[Last date of month],
        DAY
    ) + 1,
    DATEDIFF ( [First date of month], TODAY (), DAY ) + 1
)

If not right, can you share your simple data and the result what you want to output?
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @Krishna090 ;

You could try it.

Days in month =
IF (
    EOMONTH ( [First date of month], 0 ) <> EOMONTH ( TODAY (), 0 ),
    DATEDIFF (
        [First date of month],
        R_AMHS_HLY_UPTIME_DET_VW[Last date of month],
        DAY
    ) + 1,
    DATEDIFF ( [First date of month], TODAY (), DAY ) + 1
)

If not right, can you share your simple data and the result what you want to output?
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yalanwu-msft  thanks for the quick reply and similarly  I tried day before yesterday but mine is manual way. Where need to update the query based on the month no.
And below is the query I tried.

DAYS MONTH = IF (
'R_AMHS_HLY_UPTIME_DET_VW'[Month No] = 8,
DAY ( EOMONTH ( TODAY (), -3 ) ),
IF (
'R_AMHS_HLY_UPTIME_DET_VW'[Month No] = 9,
DAY ( EOMONTH ( TODAY (), -2 ) ),
IF (
'R_AMHS_HLY_UPTIME_DET_VW'[Month No] = 10,
DAY ( EOMONTH ( TODAY (), -1 ) ),
DAY ( TODAY () )
)
)
).

And ur method is working fine.
Ashish_Mathur
Super User
Super User

Hi,

Assuming there is a date column i your dataset, you should create a Calendar Table.  Create a relationship (Many to One and Single) from the Date column of your dataset to the Date column of the Calendar Table.  In the Calendar Table, write calculated column formulas to extract Year, Month name and Month number.  Sort the Month name by the Month number.  To your matrix visual, drag Year and Month name to the column section.  Write this measure

Days in month = countrows(Calendar)

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Assuming your visual shows months:

 

CALCULATE(COUNTROWS('Dates'),'Dates'[Date]<=TODAY())

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.