cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

Calculate Sales with respect to the previous Month.

Hello!

I am working with a sales base that contains all the sales of an eccommerce, this one is already worked previously and then uploaded to Power Bi.

What I want to do is two data cards, where it shows me the cumulative sales of the month and the cumulative sales of the day. To complement I want these to be colored green, if the cumulative sale of the month is greater than last month and if the sale of today is greater than the sale of the same day but last month, otherwise it is in red.

I am using the following measures

Ventas Totales = SUM(Tabla[Ventas])

Ventas Mes Anterior = 
CALCULATE([Ventas Totales], 
PREVIOUSMONTH(Ventas[Fecha]), 
REMOVEFILTERS(Ventas))

KPI MES = SWITCH(
                TRUE(),
                [Ventas Totales] < [Ventas Mes Anterior] , "#ff0000",
                [Ventas Totales] > [Ventas Mes Anterior] , "#009900",
                "FFFF00"
                )

Ventas Dia y Mes Anterior = CALCULATE([Ventas Totales],
                        DATEADD(Ventas[Fecha],-1,MONTH)
                        )

KPI DIAS= SWITCH(
                TRUE(),
                [Ventas Totales] < [Ventas Dia y Mes Anterior] , "#ff0000",
                [Ventas Totales] > [Ventas Dia y Mes Anterior] , "#009900",
                "FFFF00"
                )

Ayuda 1.PNG
When formatting a card object, it works as I want it to, but the problem is when I add a filter object that contains the categories of the products sold (Shirts, Pants, Jackets, etc.). When selecting a category to filter all the objects, they do not behave as they should (In the image the months with yellow color should be green and not Red).

If someone could help me with the right measurement so that when filtering I do the calculation well, I would appreciate them.
Ayuda 2.png

2 REPLIES 2
RicoZhou
Community Support
Community Support

Hi @Syndicate_Admin 

Your screenshot is not very clear. Could you share a sample with me and show me a clear screenshot with the result you want? This will make it easier for me to understand your requirement.

 

Best Regards,
Rico Zhou

 

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

amitchandak
Super User
Super User

@Syndicate_Admin , You should use a date table, Is there any reason to use all on table

example 

Ventas Mes Anterior = 
CALCULATE([Ventas Totales], 
PREVIOUSMONTH(Fecha[Fecha]))

 

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

 

Why Time Intelligence Fails - Power bi 5 Savior Steps for TI: https://youtu.be/OBf0rjpp5Hw

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors