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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jacobmiller2322
Frequent Visitor

calculating within an if statement

Hi,

 

Is it possible to do a calculation instead of just a "Value" in the if true and if false?

 

For example: I would like to sum everything, but if it is group blue, you double those values.

 

So in the example below, I would want to get the number 49. 

 

Basically if the group is blue, take sum of dollars that are group blue and multiply those by two, and if not, sum the rest, then get a total sum of it all.

 

Group   Dollars

Blue       4

Green     4

Green     3

Blue       2

Red        5

Red        3

Blue       4

Green     1

Yellow     2

Green      3

Blue       4

2 REPLIES 2
eliasayyy
Memorable Member
Memorable Member

yes sure 

first create measure 

Total dollars = SUM(Powerbi[Dollars])


then create your condition 

New Total = 
IF(
    MAX(Powerbi[Group]) = "Blue" , [Total dollars] * 2 , [Total dollars])


however yo uwill get wrong total 

so to fix it create a new measure 

Correct Total = 
IF(HASONEVALUE(Powerbi[Group]),[New Total],SUMX(VALUES(Powerbi[Group]),[New Total]))

annonymous1999_0-1691586085658.png

 



ValtteriN
Super User
Super User

Hi,

I recommend reading this article: 
Introducing CALCULATE in DAX - SQLBI

For your example something like this should work:

Measure 46 =

var _blue = CALCULATE(SUM('Table (35)'[Dollars]),'Table (35)'[Group]="Blue")*2
var _rest = CALCULATE(SUM('Table (35)'[Dollars]),not('Table (35)'[Group]="Blue"))
return
_blue+_rest

ValtteriN_0-1691586044038.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.