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
fcaliman
New Member

DAX: Sumif equivalent filtering by selected value

Hello,

 

I have table with 2 columns: month(Number) and Value. I am trying to build a table that would show the sum of the accumulated values by month. So i`ve tried to create a measure like this:

 

Measure= CALCULATE(SUM('Table[Value]);'Table'[Month] > SELECTEDVALUE('Table'[Month])

 

Unfortunatly it didnt work because it is not allowed to use the function "SELECTEDVALUE" in filter criterias.

 

Does anyone have a solution for this?

 

1 ACCEPTED SOLUTION

Hi @fcaliman,

 

If your month is based on number maybe you can use:

 

Measure =
CALCULATE (
    SUM ( Table[Value] );
    FILTER ( ALL ( Table[Month] ); Table[Month] < MAX ( Table[Month] ) )
)

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

4 REPLIES 4
fcaliman
New Member

Hello,

 

I have table with 2 columns: month(Number) and Value. I am trying to build a table that would show the sum of the accumulated values by month. So i`ve tried to create a measure like this:

 

Measure= CALCULATE(SUM('Table[Value]);'Table'[Month] > SELECTEDVALUE('Table'[Month])

 

Unfortunatly it didnt work because it is not allowed to use the function "SELECTEDVALUE" in filter criterias.

 

Does anyone have a solution for this?

 

Hi,

 

"Accumulation over time period" questions are very easy to solve if you use the Date/Time Intelligence functions.  You must have a Date column in your data to use those functions.  Do you have a Date column?  If not, we can always build a date field if you have Year and Month in seperate columns.  Do you have year and Month columns in your base data.  If yes, then share that data and show the expected result.


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

Hi @fcaliman,

 

If your month is based on number maybe you can use:

 

Measure =
CALCULATE (
    SUM ( Table[Value] );
    FILTER ( ALL ( Table[Month] ); Table[Month] < MAX ( Table[Month] ) )
)

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

HI

 

So, you want to select some value in slicer and calculate the measure accordingly ?

 

The below one will work, but make sure if you select multiple values in slicer, the selected value will return blank.

Measure 3 = CALCULATE(SUM(Table1[Value]),FILTER(Table1,MONTH(Table1[Date])>MONTH(SELECTEDVALUE(Table1[Date]))))

 

Thanks
Raj

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.