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
ApurvaKhatri
Helper III
Helper III

Previous month data

Hello I have data as follows

 

Data:

 

Balance   As of Date   Data Segregation  

10000   2017-06-30      Current                    

40000   2017-06-30      >1

30000   2017-06-30      Current

20000   2017-06-30      > 2

10000   2017-06-30     Current

10000   2017-06-30     >2

20000   2017-06-30    >2

50000   2017-07-31   Current

10000   2017-07-31   Current

50000 2017-07-31    >1

15000   2017-07-31   >2

50000   2017-07-31   >1

 

Measures

Current M1 = Calculate( sum(Balance),Filter(Table,table[Data Segregation  ] = “Current”

>1 M1 = Calculate( sum(Balance),Filter(Table,table[Data Segregation  ] = “> 1”

>2 M1 = Calculate( sum(Balance),Filter(Table,table[Data Segregation  ] = “> 2”

 

 

Data Display Output

Date        Current M1                                     >1 M1              >2 M1 

May            sum(Balance) of June

June            sum(Balance) of July

July               sum(Balance) of Aug

 

I want to display sum(balance) of next month into current month

 

 

How do I acheive this?

 

 

 

1 ACCEPTED SOLUTION
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @ApurvaKhatri,

Use your sample table to test, get expected result.

1. Create a Calendar Table and build a relatioship from the your Fact Table(named Table2 in my formula) to your Calenda Table.

Calendar = CALENDAR(MIN(Table2[As of Date]),MAX(Table2[As of Date]))

3.PNG

Create calculated column to get Year-Month column using the formula.

Year-Month = YEAR('Calendar'[Date])&FORMAT('Calendar'[Date],"MMM")

1.PNG

2. Create measure using your formula below.

Current M1 =
CALCULATE (
    SUM ( Table2[Balance] ),
    FILTER ( Table2, Table2[ Data Segregation] = "Current" )
)

>1 M1 =
CALCULATE (
    SUM ( Table2[Balance] ),
    FILTER ( Table2, Table2[ Data Segregation] = ">1" )
)

>2 M2 =
CALCULATE (
    SUM ( Table2[Balance] ),
    FILTER ( Table2, Table2[ Data Segregation] = ">2" )
)

Previous-Month CurrentM1 = CALCULATE(Table2[Current M1],NEXTMONTH('Calendar'[Date]))

Previous-Month >1M1 = CALCULATE(Table2[>1 M1],NEXTMONTH('Calendar'[Date]))

Previous-Month >2M2 = CALCULATE(Table2[>2 M2],NEXTMONTH('Calendar'[Date]))

 

Create a table visual, select the Calendar[Year-Month] and all the measure as values level.

2.PNG
Best Regards,
Angelia

View solution in original post

2 REPLIES 2
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @ApurvaKhatri,

Use your sample table to test, get expected result.

1. Create a Calendar Table and build a relatioship from the your Fact Table(named Table2 in my formula) to your Calenda Table.

Calendar = CALENDAR(MIN(Table2[As of Date]),MAX(Table2[As of Date]))

3.PNG

Create calculated column to get Year-Month column using the formula.

Year-Month = YEAR('Calendar'[Date])&FORMAT('Calendar'[Date],"MMM")

1.PNG

2. Create measure using your formula below.

Current M1 =
CALCULATE (
    SUM ( Table2[Balance] ),
    FILTER ( Table2, Table2[ Data Segregation] = "Current" )
)

>1 M1 =
CALCULATE (
    SUM ( Table2[Balance] ),
    FILTER ( Table2, Table2[ Data Segregation] = ">1" )
)

>2 M2 =
CALCULATE (
    SUM ( Table2[Balance] ),
    FILTER ( Table2, Table2[ Data Segregation] = ">2" )
)

Previous-Month CurrentM1 = CALCULATE(Table2[Current M1],NEXTMONTH('Calendar'[Date]))

Previous-Month >1M1 = CALCULATE(Table2[>1 M1],NEXTMONTH('Calendar'[Date]))

Previous-Month >2M2 = CALCULATE(Table2[>2 M2],NEXTMONTH('Calendar'[Date]))

 

Create a table visual, select the Calendar[Year-Month] and all the measure as values level.

2.PNG
Best Regards,
Angelia

Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

  1. Create a Calendar Table and build a relatioship from the As of Date column of your Data Table to the Date column of your Calenda Table
  2. In the calendar table, extract the Year and Month from the Date column by using =YEAR(Calendar[Date]) and =FORMAT(Calendar[Table],"mmmm")
  3. In the visual, drag the Year and month columns from the calendar table
  4. Write the following calculated field formulas

=CALCULATE(SUM(Data[Balance]),NEXTMONTH(Calendar[Table]))

 

Hope this helps.


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

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 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.

Top Solution Authors