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

Sum of a measure with boolean values

Hi,

 

I have a measure that calculates volume for a particular date by SAP ID - Measure1.

I want to use Measure1 to calculate the total count of SAP ID with volume >0 to create another measure.

I tried using

Measure2=

var Count_helper=IF([Measure1]>0,1,0)
return SUMX(VALUES('Table'),Count_helper)
 
But it did not work
 

Measure2.JPG

 

 

 

Measure1=var m1=MAX(date_test[year_month])
var Currentdate=DATE(year(m1),MONTH(m1)-12,DAY(m1))
var Previousdate=DATE(year(Currentdate),MONTH(Currentdate)-12,DAY(Currentdate))
var Result = CALCULATE(
    SUM('Datas Vol'[Total Volume]),FILTER(Dates,Dates[date]>=Previousdate && Dates[date]<Currentdate))
return Result

 

 

6 REPLIES 6
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

Referring to the example above, you can try to create such a measure for your needs:

Measure2 = 
VAR t =
  CALCULATE (
    DISTINCTCOUNT('Table'[Colunmname]),
    FILTER ( 
      ALLSELECTED('Table'), 
      [Measure 1] > 2 
    )
   )
RETURN
  IF ( [Measure 1] > 2, t, 0 )

 image.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

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

PaulDBrown
Community Champion
Community Champion

@Anonymous 

Try:

Count = CALCULATE(DISTINCTCOUNT(table [SAP ID]), FILTER(Table, [Measure1> 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.






Anonymous
Not applicable

for some reason countrow is not working

@Anonymous 

Apologies since I saw you wanted the count of unique values. I changed the meaures to:

Count = CALCULATE(
           DISTINCTCOUNT(Table [SAP ID]), 
           FILTER(Table, [Measure1> 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.






parry2k
Super User
Super User

@Anonymous not fully clear what is the ask here, post sample data and the expected output to get your answer quickly.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

ID Volume

1   10

2   20

3   30

4   8

5   7

6   5

7  10

 

I need to find the sum of the Volume where Volume => 10

Please note Volume here is a measure

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.