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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculating an index from true/false data - SUM.IF formula

Hi 

 

I'm used to apply SUM.IF in Exel but I don't know how do the same via a Measure in Power BI. 

 

I will illustrate my problem by an example. Let's say I have this data: 

 

Sales opportunity, unique#Sales prizeRevenueIs the car blue?Is the car a 4WDDoes the car have backseats?
1110025TrueFalseTrue
1230040FalseFalseFalse
1325035FalseFalseFalse
1417520FalseTrueFalse
1510020FalseFalseFalse
167510TrueFalseTrue
1737555TrueTrueTrue

 

If I want to calculate and index that tells my what the average revenue is on all sales, I use this formula to create a Measure: Rev_average = (SUM (Data[Revenue]))/(COUNTROWS(Data)) * 100 

 

My problem is that I also want to calculate revenue based on the entries where and only if one of the following values is true: “Is the car blue?”, “Is the car a 4WD”, ”Does the car have backseats?”  So if all values is false it will not count in the average revenue.

 

Does anyone know how to do that?

 

BR

Anders

2 ACCEPTED SOLUTIONS

1. create the conditional filed which i mention in first reply on this post like this.

1.JPG

 

 

2. Create one calculation or Directly drag the Value measure into the card and choose as Average 

 3.JPG

 

3. Darg the final Condtional Column into visual filter  and choose greater than "0" Thats it Dude.

 2.JPG

 

View solution in original post

Yes, @Baskar 's solution works fine for that purpose.

 

But if you're after a more robust solution, this measure would do:

 

NewAverage = CALCULATE(AVERAGE('Table2'[Revenue]), FILTER(Table2, 'Table2'[Include]=1))

 

No need to switch to Average in the report-design then.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

24 REPLIES 24

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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