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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
cglinn
Regular Visitor

Aggregate a measure after Filtering

I'm very new to Power BI.  I've read through many of the posts here but haven't been able to find a resolution, so hoping that someone can help.

 

I'm trying to populate a single line Card Visual based on the selection of dates where the sum of the variance for the combination of Region, Group, and selected dates is negative, as shown below.

 

cglinn_1-1621683758186.png

 

cglinn_4-1621683554246.png

 

 
 

Any suggestions?

 

11 REPLIES 11
PaulDBrown
Community Champion
Community Champion

Did you try the measure I posted?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

You could try:

Expected card total =

VAR _Variance = SUM(Table[Variance])

RETURN

CALCULATE(_Variance,  FILTER(Table, _Variance < 0))





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






mahoneypat
Microsoft Employee
Microsoft Employee

If you provide example data in copy/paste format, a specific expression can be provided.  However, you can try a pattern like this to get your result.

 

Just Negative =
VAR summary =
    ADDCOLUMNS (
        SUMMARIZE ( Table, Table[Region], Table[Group], Date[YearMonth] ),
        "cVariance", [YourVarianceMeasure]
    )
RETURN
    SUMX ( FILTER ( summary, [cVariance] < 0 ), [cVariance] )

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Pat,

 

This solution is very close.  It works if just one month is selected.  However, if multiple months are selected, the identification of a negative value for the aggregated total for the multiple months is not working properly.  I've been able to get it to work if put in a table visualization with the Group included.  However, once it goes into a Card visualization the calculation does not work correctly. 

 

The desired result would be if April and May are selected in the slicer then:

For each combination of Region/Group, total the resulting value from if(sum(April Variance, May Variance)<0, sum(April Variance, May Variance),0) to create a single total number for the entire population (as shown on the last row below.

 

Thanks again,

Everytime I try to copy/paste the data and post the reply I get an HTML error.  So, here's an attempt a delimited list:

 

Region,Group,Month,Variance
1,A,Apr-21,"($817,554)"
1,A,May-21,"($1,013,666)"
1,A,Jun-21,"($328,526)"
1,B,Apr-21,"$231,961 "
1,B,May-21,"$171,879 "
1,B,Jun-21,"($99,629)"
1,C,Apr-21,"$111,776 "
1,C,May-21,"$6,153 "
1,C,Jun-21,"$304,564 "
1,D,Apr-21,"$110,964 "
1,D,May-21,"($24,477)"
1,D,Jun-21,"($22,846)"
1,E,Apr-21,"($157,251)"
1,E,May-21,"($60,183)"
1,E,Jun-21,"($60,183)"
1,F,Apr-21,"($1,567,083)"
1,F,May-21,"$201,826 "
1,F,Jun-21,"$33,638 "

Hi,

Share the link from where i can download your PBI file.


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

Here's a test file I put together:  Link

You have selected 3 months in the slicer.  How does one calculate variance for 3 months?


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

Still looking for a solution to this issue.  Any other suggestions?  Thank you!

Hi,

I just do not understand your question.  May be someone else will help you.  Sorry.


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

It would be the sum of the monthly variances (included in the dataset) in total, then check if it is negative or not.  

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors