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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Total sum error with sum filters

Hello everybody,

 

I'm having problems summing the total of the tables, I have 2 products that have 2 release dates, it was launched with a quantity on each date, then I need to know how its sales performance was, but for example, I have a sales total in a period 636 sales.

 

BrendowFreire2_0-1663340682594.png

I'm using this measurement:

Varejo 4 Sem =
   VAR DataLancamento = MAX(Lancamento_Vermelha[DT_Lançamento])
   VAR DataMax = DataLancamento + 41
   VAR DataMin = DataLancamento + 41
RETURN
    CALCULATE(
        [Venda Fisica],
  DATESBETWEEN(Calendario[Data],MIN(Lancamento_Vermelha[DT_Lançamento])-41,MAX(Lancamento_Vermelha[DT_Lançamento])+41)))
 
 
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create measure.

Measure_Varejo 4 Sem =
var _table1=
SUMMARIZE('Lancamento_Vermelha','Lancamento_Vermelha'[DT_Lancamento],"Value",[Varejo 4 Sem])
return
IF(
    HASONEVALUE('Lancamento_Vermelha'[DT_Lancamento]),
    [Varejo 4 Sem],
    SUMX(_table1,[Value]))

2. Result:

vyangliumsft_0-1663569254876.png

 

Best Regards,

Liu Yang

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

View solution in original post

10 REPLIES 10
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create measure.

Measure_Varejo 4 Sem =
var _table1=
SUMMARIZE('Lancamento_Vermelha','Lancamento_Vermelha'[DT_Lancamento],"Value",[Varejo 4 Sem])
return
IF(
    HASONEVALUE('Lancamento_Vermelha'[DT_Lancamento]),
    [Varejo 4 Sem],
    SUMX(_table1,[Value]))

2. Result:

vyangliumsft_0-1663569254876.png

 

Best Regards,

Liu Yang

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

tamerj1
Super User
Super User

Hi @Anonymous 
Please try the following

Varejo 4 Sem =
SUMX (
    VALUES ( Lancamento_Vermelha[Material Pai] ),
    CALCULATE (
        VAR DataLancamento =
            MAX ( Lancamento_Vermelha[DT_Lançamento] )
        VAR DataMax = DataLancamento + 41
        VAR DataMin = DataLancamento - 41
        RETURN
            CALCULATE (
                [Venda Fisica],
                DATESBETWEEN ( Calendario[Data], DataMin, DataMax )
            )
    )
)
Anonymous
Not applicable

It still hasn't happened, in fact I think the error is in the VAR DataLaunching, because if I put MAX, it brings me the value of 08/22/2021, and if I put the minimum it brings me the value of 11/15/2021 .

BrendowFreire2_0-1663348285047.png

how do i return exactly then the date in question?

 

@Anonymous 
would you please copy/paste the code so I can edit?

Anonymous
Not applicable

sorry, how do i do that? what code ?

@Anonymous 
The [Varejo 4 Sem] measure. Please copy the dax formula and paste it in a reply so I can edit.

Anonymous
Not applicable

Atacado 4 Sem = 
   VAR DataLancamento = MAX(Lancamento_Vermelha[DT_Lançamento])
   VAR DataMax = DataLancamento + 28
   VAR DataMin = DataLancamento - 41
RETURN
    SUMX(
        VALUES(Cadastro_Material[Material Pai]),
    CALCULATE(
        [Venda Fisica Atacado],        DATESBETWEEN(Calendario[Data],MIN(Lancamento_Vermelha[DT_Lançamento])-41,MAX(Lancamento_Vermelha[DT_Lançamento])+28)))

 

so ?

@Anonymous 

Please try

 

Atacado 4 Sem =
SUMX (
    SUMMARIZE (
        Cadastro_Material,
        Cadastro_Material[Material Pai],
        Cadastro_Material[DT_Lancamento]
    ),
    CALCULATE (
        VAR DataLancamento =
            MAX ( Lancamento_Vermelha[DT_Lançamento] )
        VAR DataMax = DataLancamento + 28
        VAR DataMin = DataLancamento - 41
        RETURN
            CALCULATE (
                [Venda Fisica Atacado],
                DATESBETWEEN ( Calendario[Data], DataLancamento, DataMax )
            )
    )
)

 

Anonymous
Not applicable

It kind of worked, but now when I talk about big dates it brings me a very large amount of the released,

BrendowFreire2_0-1663355456095.png

Do I have to do something to that extent for it to get a filter?

Or for example, I have a release on 08/01/2022, so I go ahead and go back 41 days, which is between the period we did in the measure of DataMin, DataMax.

I just apply a filter of Year and month times.

On 01/08/2002 I launched 27800, but it is saying that I sold 282,924, even though the field Cadastro_Material[Material Parent] would be the product code.


I'm sorry for this.

@Anonymous 

I'm sorry but I don't think I properly understand. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Top Kudoed Authors