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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
J3
Frequent Visitor

Calcular la suma de ventas en un solo año y por mes

Hola, necesito calcular la suma de ventas para un período en especifico (solo un año) y que al graficar pueda tener el detalle de ventas por cada mes de ese año (2022) para graficar un grafico de líneas. En la BD tengo datos desde varios años y no puedo ocupar filtro de año pues necesito en esa misma gráfica otra línea con datos de 2023

 

adjunto ejemplo datos 

FechaVentas
01-02-2021350
03-03-2021250
09-03-2021200
28-05-2021400
01-01-2022200
02-03-2022500
01-04-2022200
31-05-202220
30-06-2022200
29-08-2022200
27-11-2022580
27-12-2022250
01-03-2023500
01-01-2023300
1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @J3 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create measures. 

Sales 2022 = CALCULATE(SUM('Table'[Ventas]), YEAR('Table'[Fecha])=2022)
Sales 2023 = CALCULATE(SUM('Table'[Ventas]), FILTER(ALLSELECTED('Table'),YEAR('Table'[Fecha])=2023))
Flag = IF(YEAR(MAX('Table'[Fecha]))=2022 ||  YEAR(MAX('Table'[Fecha]))=2023,1,0)

(3) Then the result is as follows.

vtangjiemsft_0-1693535285293.png

 

 

If the above one can't help you get the desired result, please give your expected output for the visual object. Thank you.

 

Best Regards,

Neeko Tang

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

1 REPLY 1
v-tangjie-msft
Community Support
Community Support

Hi @J3 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create measures. 

Sales 2022 = CALCULATE(SUM('Table'[Ventas]), YEAR('Table'[Fecha])=2022)
Sales 2023 = CALCULATE(SUM('Table'[Ventas]), FILTER(ALLSELECTED('Table'),YEAR('Table'[Fecha])=2023))
Flag = IF(YEAR(MAX('Table'[Fecha]))=2022 ||  YEAR(MAX('Table'[Fecha]))=2023,1,0)

(3) Then the result is as follows.

vtangjiemsft_0-1693535285293.png

 

 

If the above one can't help you get the desired result, please give your expected output for the visual object. Thank you.

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors