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

Calculated Sum of values filtered by date and selected value

Is there anyway to achieve this?

I want to measure some values from a Table
I want to see the number of events from yesterday, last week and last month compared with today's events, current week and current month to see if we had an increase or decrease in the number of events

I have already achieve that with this fomula 

Yesterday = CALCULATE(SUM(Alarmas_Estacion[Eventos]),FILTER(Alarmas_Estacion,Alarmas_Estacion[Fecha sin Hora] = TODAY()-1)) (I have a similar for last week and month)

But this sums all the values in the table and I want to see this values filtered by the "Estacion" name 

 
 

image_2020-10-03_115133.png
I want to see how many events does the "estacion" DJM305 had yesterday vs todays 
and if on this table the users selects "DJM369" the values from events change to the "estacion" selected 


similar to PowerApps ThisIte.SelectedText.Value 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

Create a measure as below:

Yesterday =
CALCULATE (
    SUM ( Alarmas_Estacion[Eventos] ),
        FILTER ( ALL(Alarmas_Estacion), Alarmas_Estacion[Fecha sin Hora] = TODAY () - 1&&Alarmas_Estacion[Estacion]="DJM305" )
    )
)

 

Best Regards,
Kelly

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

View solution in original post

4 REPLIES 4
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

Create a measure as below:

Yesterday =
CALCULATE (
    SUM ( Alarmas_Estacion[Eventos] ),
        FILTER ( ALL(Alarmas_Estacion), Alarmas_Estacion[Fecha sin Hora] = TODAY () - 1&&Alarmas_Estacion[Estacion]="DJM305" )
    )
)

 

Best Regards,
Kelly

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

jdbuchanan71
Super User
Super User

@Anonymous 

Try adding KEEPFITLERS to your measure.

Yesterday =
CALCULATE (
    SUM ( Alarmas_Estacion[Eventos] ),
    KEEPFILTERS (
        FILTER ( Alarmas_Estacion, Alarmas_Estacion[Fecha sin Hora] = TODAY () - 1 )
    )
)
Anonymous
Not applicable

It works but I can only used in one DAX formula

If I use KEEPFILTERS in Yesta¿erday formula then I cannot used it in Todays or Last Month 
it creates a circular reference between them

 

@Anonymous 

I beleive that is becaue you are using the FILTER in your meaure.  Take a look at this article about working with weeks in time intelligence funcitons.

https://www.daxpatterns.com/week-related-calculations/

It is part of a larger series on time patterns that you might find useful.

https://www.daxpatterns.com/time-patterns/

 

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.