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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

Calculate ignoring the date and adding up all values instead of the line values

Hello, I have the table  below  with a bunch of columns, each line gives me a product and on another non related table I have the correspondency  (from-to) of each of theses products ids and their targets.

talleslessa_0-1618414081834.png

I am using the fofllowing DAX to return the "venda categoria espelho"

 

Venda Categoria Espelho =
VAR codespelho = MAX('Produto espelho'[cod_target]) -- reads that from to table and returns the code of the corresponding item
RETURN
CALCULATE(SUM('Venda Diária'[venda_brut]),
            FILTER(
                   ALL('Venda Diária'),                                        -- clears all filters from the table and gives me the SUM using codespelho
                   'Venda Diária'[codpro] = codespelho  

           )
)


However as you can see it messes up because it is ignoring the outer filter of date (which is set to march 2021and is also displayed on one of the columns on the table as well) and because of that, it not only fills the table with non filtered data (each row shown after  "elim.odor..." is outside the daterange set by the outer filter) but also, per row it is returning me the SUM of all dates instead of only the date defined by that row.

 

I understand the it is because when filtering for the whole table I end up removing all filters, but i cant get this to work an other way.

 

Help Appreciated

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Managed to make it work, in the end I ended up clearing all filters, creating some variables to store the data I needed for the filters, adding those variables on the tables(date and "venda diária") by splitting the date column into year and another column for month. And using those variales as joinned arguments on the filter function using the AND function (&&)

talleslessa_0-1618420658768.png

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Managed to make it work, in the end I ended up clearing all filters, creating some variables to store the data I needed for the filters, adding those variables on the tables(date and "venda diária") by splitting the date column into year and another column for month. And using those variales as joinned arguments on the filter function using the AND function (&&)

talleslessa_0-1618420658768.png

 

AlexisOlson
Super User
Super User

Instead of clearing all filters on the table with ALL('Venda Diária'), maybe try only clearing the specific filters you do want to be cleared.

Anonymous
Not applicable

I want to kee just the date, but i cant get REMOVEFILTERS to work

Anonymous
Not applicable

By adding another condition to the filter i get rid of the extra lines, but the values are still wrong for some reason it is summing up the full period

Venda Categoria Espelho =
VAR codespelho = MAX('Produto espelho'[cod_target])
VAR datax = MAX('Venda Diária'[data])
RETURN
CALCULATE(SUM('Venda Diária'[venda_brut]),
FILTER(
all('Venda Diária'),
'Venda Diária'[codpro] = codespelho&&
datax
)
)

talleslessa_0-1618419038440.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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