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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
unnijoy
Post Prodigy
Post Prodigy

Find sum based on filter

I have two column Month and Status (1 or 0). In month i have month from Jan 2001 to June 2019. I have a month slicer. I need help in creating a formula in sucha way that when i select a particular month i need to get the sum on all 1 from Jan 2001 till up to selected month. Below is the example.

Month Status
Jan-010
Feb-011
Mar-011
Apr-010
May-011
Jun-010
Jul-011
Aug-011
Sep-011
Oct-010
Nov-011
Dec-010
Jan-021
Feb-020
Mar-021
Apr-020
Jan-161
Feb-160
Mar-161
Jan-191
Feb-191
Mar-190
Apr-191
May-190

From the above example from the slicer if i select April 2019 i should the sum of 1 from the begining (Jan 2001) till April 2019 and give 14. And if i select Mar 2002 it should calculate the sum of 1 from Jan 2001 till up to Mar 2002 and gvie the output as 9.

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

Hi @unnijoy ,

 

By my test, you could create a irrelative table as a slicer to filter the values. I create a sample using two ways you can have a try.

 

  1. Create a new table. And the values I added is the same as your sample data. There is no relationship between two tables.1.png
  2. Create measures.

Method 1:

Note : it will show the original values and the expected total.

Measure =
var a = SELECTEDVALUE(Table2[Month ])
return CALCULATE(SUM(Table1[Status]),FILTER(Table1,MAX(Table1[Month ])<=a))

Measure 2 = IF(ISFILTERED(Table2[Month ]),CALCULATE(SUMX(Table1,Table1[Measure]),ALLEXCEPT(Table1,Table1[Month ])),SUM(Table1[Status]))

Method 2:

Note: It will show blank by default.

Measure 3 = IF(ISFILTERED(Table2[Month ]) && MAX(Table1[Month ])<=SELECTEDVALUE(Table2[Month ] ),SUMX(FILTER(ALL(Table1),'Table1'[Month ] <=SELECTEDVALUE(Table2[Month ])),Table1[Status]))

2.jpg

Best Regards,

Xue Ding 

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

 

Best Regards,
Xue Ding
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

1 REPLY 1
v-xuding-msft
Community Support
Community Support

Hi @unnijoy ,

 

By my test, you could create a irrelative table as a slicer to filter the values. I create a sample using two ways you can have a try.

 

  1. Create a new table. And the values I added is the same as your sample data. There is no relationship between two tables.1.png
  2. Create measures.

Method 1:

Note : it will show the original values and the expected total.

Measure =
var a = SELECTEDVALUE(Table2[Month ])
return CALCULATE(SUM(Table1[Status]),FILTER(Table1,MAX(Table1[Month ])<=a))

Measure 2 = IF(ISFILTERED(Table2[Month ]),CALCULATE(SUMX(Table1,Table1[Measure]),ALLEXCEPT(Table1,Table1[Month ])),SUM(Table1[Status]))

Method 2:

Note: It will show blank by default.

Measure 3 = IF(ISFILTERED(Table2[Month ]) && MAX(Table1[Month ])<=SELECTEDVALUE(Table2[Month ] ),SUMX(FILTER(ALL(Table1),'Table1'[Month ] <=SELECTEDVALUE(Table2[Month ])),Table1[Status]))

2.jpg

Best Regards,

Xue Ding 

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

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.