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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

undefined

Hi Teams

I have facing a problem.

We want if the date is after 16 then it shows the previous month data,

when the data is before 15 then it shows the previous to previous months data.

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

Please provide some sample data and expected results.

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Add this as a custom step in your M query:

 

Table.SelectRows(
    previousStep, each
    let
        Date.Today = Date.From(DateTime.LocalNow())
    in
    if Date.Day(Date.Today) >= 16
    then
        Date.Month([yourDate]) = Date.Month(Date.AddMonths(Date.Today, -1))
        and Date.Year([yourDate]) = Date.Year(Date.AddMonths(Date.Today, -1))
    else
        Date.Month([yourDate]) = Date.Month(Date.AddMonths(Date.Today, -2))
        and Date.Year([yourDate]) = Date.Year(Date.AddMonths(Date.Today, -2))
)

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Anonymous
Not applicable

Not Working 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.