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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
gelsonwirtijr
Frequent Visitor

total value different from expected

Hey guys. I'm trying to make a dax measure that returns the sales value of products that are in the aging range "From 91 to 120 days", that is, the sales value of products that have the most recent date in the fInventario table with fInventario[Aging Range] = "From 91 to 120 days". In the image below I have the closest I could get to the expected result. I was able to return the desired products and the sales value, but the Totals are different. Can anyone help me?

gelsonwirtijr_0-1739198030023.png

gelsonwirtijr_2-1739198158014.png

 

My measure:

VAR DataMaisRecente =
    CALCULATE(
        MAX(fInventario[Data]),
        ALLEXCEPT(fInventario, fInventario[IdProduto])
    )
VAR VerificaAging =
    CALCULATE(
        COUNTROWS(fInventario),
        FILTER(
            fInventario,
            fInventario[Data] = DataMaisRecente &&
            fInventario[Range de aging] = "De 91 a 120 dias" &&
            [Valor estoque atual] > 0
        ),
        ALLEXCEPT(fInventario, fInventario[IdProduto])
    )
RETURN
IF(VerificaAging > 0, [Vendas brutas], BLANK())



expected result:

gelsonwirtijr_1-1739198061657.png

gelsonwirtijr_3-1739198172350.png

pbix is ​​available at:
https://drive.google.com/drive/folders/1LwzYKVU4xDD5KfXCiLVN_c70LT6xG3bc?usp=sharing

2 REPLIES 2
bhanu_gautam
Super User
Super User

@gelsonwirtijr , Try using 

SalesValueAgingRange =
VAR DataMaisRecente =
CALCULATE(
MAX(fInventario[Data]),
ALLEXCEPT(fInventario, fInventario[IdProduto])
)
VAR VerificaAging =
CALCULATE(
COUNTROWS(fInventario),
FILTER(
fInventario,
fInventario[Data] = DataMaisRecente &&
fInventario[Range de aging] = "De 91 a 120 dias" &&
[Valor estoque atual] > 0
),
ALLEXCEPT(fInventario, fInventario[IdProduto])
)
VAR SalesValue =
IF(VerificaAging > 0, [Vendas brutas], BLANK())
RETURN
SUMX(
VALUES(fInventario[IdProduto]),
SalesValue
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






it didn't work
gelsonwirtijr_0-1739200357239.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.

Top Solution Authors