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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ElenaGrom
Frequent Visitor

SUMIF for a measure based on another measure value

Hello Community,

 

I am using a table visual like on the screenshot below. The first 5 columns (Customer, Dates and Amount) are taken from different tables. Next, I have a measure "Scenario", which returns a text value. This measure makes a comparison between the 3 dates from the left and asignes a certain "scenario code". In reality the comparison is done based on 6 fields, so the code length is 6 characters.

 

Also, I am using a date slicer to identify the reporting period. i.e. the fist 5 columns are dynamically updated based on user selection, and therefore the scenario code is recalculated every time.

 

PROBLEM:

I need to find a way to calculate the subtotal of the amount for each scenario code. In Excel I would do it using the SUMIFS function. In DAX I tried Calculate(SUM....; SUMX but they need a reference to a table or to a column. In my case I need to reference just a value from the measure, as there is no table behind.

 

Can anyone help how can this be done?

Thank you in advance!

 

SumIFExample.png

1 ACCEPTED SOLUTION
onurbmiguel_
Power Participant
Power Participant

Hello 

 

Try to create a column for the scenario: 

Scenario = 
if( 
    'Table'[Reg Date] < 'Table'[Trans Date] , "Y" , "N" 
)
&
if(
    'Table'[End Date]>'Table'[Trans Date] ,"Y", "N"
)

then create the mesaure

SubTotal = 
var _scenario = SELECTEDVALUE('Table'[Scenario])
return 
CALCULATE(
    SUM('Table'[Amount]),
    REMOVEFILTERS('Table'[Customer]),
    'Table'[Scenario]=_scenario
    )

onurbmiguel__1-1675876539112.png

 

onurbmiguel__0-1675876464710.png

 

Best regards

Bruno Costa | Solution Supplier

 

Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 👍

Take a look at the blog: PBI Portugal 

wp-1586527108426

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


View solution in original post

3 REPLIES 3
onurbmiguel_
Power Participant
Power Participant

Hi ElenaGrom

 

Did I help you to answer your question? Accepted my post as a solution! 👍

 

Take a look at the blog: PBI Portugal 

wp-1586527108426

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


onurbmiguel_
Power Participant
Power Participant

Hello 

 

Try to create a column for the scenario: 

Scenario = 
if( 
    'Table'[Reg Date] < 'Table'[Trans Date] , "Y" , "N" 
)
&
if(
    'Table'[End Date]>'Table'[Trans Date] ,"Y", "N"
)

then create the mesaure

SubTotal = 
var _scenario = SELECTEDVALUE('Table'[Scenario])
return 
CALCULATE(
    SUM('Table'[Amount]),
    REMOVEFILTERS('Table'[Customer]),
    'Table'[Scenario]=_scenario
    )

onurbmiguel__1-1675876539112.png

 

onurbmiguel__0-1675876464710.png

 

Best regards

Bruno Costa | Solution Supplier

 

Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 👍

Take a look at the blog: PBI Portugal 

wp-1586527108426

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


Dear Onurbmiguel,


Many thanks for your quick response.

 

Sorry for the delay with the answer - i was playing around with the offered solution. Yes, what you suggest works perfectly in the example which I gave in this topic and I could reproduce it at my side. I will mark it as an accepted solution.


My issue is - in my real life case I cannot have the scenario column in the same table where i have customers and amounts, because the scenario value is really dynamic and based on what user selects in slicers - the scenario value may be different for the same data set.

E.g.

Customer1 - in the current example has the value "YY", but he may as well have "YN" etc. 

In reality there is a Scenario table, which says "YY" = Existing Customer, "NY" = New customer etc. But this table cannot have any relation to the main table from which the amounts are analyzed.


This is my fault, I should have asked it differently.  I will open a new topic for that with more details.

Thank you again for your help, your solution solves exactly the problem as it was described!


Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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