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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
santiagouc
Frequent Visitor

Sum of a variable with multiple selected values and filters

Hello!

 

I need to create a measure that sum a column of a table filter by the date and the name of  the selected value but in this case is posible to have multiple values selected. So far I have this measure

 

Potencial Actual =
var _pozo = SELECTEDVALUE(RecoleccionIny[NombreRecobro])

RETURN
CALCULATE(SUM(MedidoresLiquido[Potencial]);FILTER(MedidoresLiquido;AND(MedidoresLiquido[Fecha].[Date]=TODAY()-1;MedidoresLiquido[CodPozo]= _pozo)))
 
when I select only one value of RecoleccionIny[NombreRecobro] works fine but when I select more than one the measure doesn't calculate the sum of MedidoresLiquido[Potencial] I tried to use the formula "IN" but doesn't work. I will appreciate the help!
3 REPLIES 3
v-yohua-msft
Community Support
Community Support

Hi, @santiagouc 

 

You may be able to try the following DAX expressions:

 

Potencial Actual =
CALCULATE(
    SUM(MedidoresLiquido[Potencial]),
    FILTER(
        ALLSELECTED(RecoleccionIny),
        MedidoresLiquido[CodPozo] IN VALUES(RecoleccionIny[NombreRecobro])
    ),
    MedidoresLiquido[Fecha].[Date] = TODAY() - 1
)


This measure is used to consider all the choices made in and then filter based on those choices. 

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)

Best Regards

Yongkang Hua

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

 

Ashish_Mathur
Super User
Super User

Hi,

The second condition within the AND() function seems redundant and therefore so does the AND() function itself.  Create a Calendar Table with a relationship (Many to One and Single) from the Fecha column to the Date column of the Calendar Table.  Simplify your measure to:

 

Measure = CALCULATE(SUM(MedidoresLiquido[Potencial]);datesbetween(Calendar[date];today()-1;today()-1))

 


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

Hi @santiagouc would you be so kind to share sample table ? 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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