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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

Previous Month Sales on Smart Card

Friends of the PowerBi community, I have a question: How do I visualize last month's sales on a "smart card"?

I have the following formula but the card shows me the value of the sum of the sales year 2020 and 2021.

Previous Month Sale = CALCULATE([Sale],DATEADD('Calendar'[Date],-1,MONTH))
I need the August veins on this card as we are in September,
Pregunta PowerBi.jpg
4 ACCEPTED SOLUTIONS

Good Morning: Of course with pleasure!

1. Initially I created in my database a column called total sale.

Total Sale = 'MiAguila Database'[Base Price]*'MiAguila Database'[Quantity delivered]

Pregunta PowerBi1.jpg

2. I subsequently created a measure called "Sale"

Sale = SUM('MyAguila Database'[Total Sale])

Pregunta PowerBi2.png

View solution in original post

Hi @Syndicate_Admin 

 

Good Night😉

Try this measure:

 

Previous Month Sale  =
VAR _T =
    TODAY ()//or any date 
VAR _Y =
    YEAR ( _T )
VAR _M =
    MONTH ( _T )
VAR _LD =
    DATE ( _Y, _M, 1 ) - 1
VAR _FD =
    DATE ( _Y, _M - 1, 1 )
RETURN
    CALCULATE (
        [Sale],
        FILTER ( 'Calendar', 'Calendar'[Date] <= _LD && 'Calendar'[Date] >= _FD )
    )

 

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

Appreciate your Kudos!!

View solution in original post

Thank you very much, the formula worked for me, although the novelty I have is that when filtering by month I would be gusaria to show me the sales of the month anteror of the filtering.

In this case I filtered by "Julio", I would be told to bring me the sales of "June".

pREGUNTA pOWERbI3.jpg

View solution in original post

Hi @Syndicate_Admin 

 

In the previous code rather than 

VAR _T =
    TODAY ()

use SELECTEDVALUE.

 

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

Appreciate your Kudos!!

 

 

View solution in original post

5 REPLIES 5
VahidDM
Super User
Super User

Hi @Syndicate_Admin 

 

Can you please share the [Sale] measure codes here?

 

Appreciate your Kudos✌️!!

Good Morning: Of course with pleasure!

1. Initially I created in my database a column called total sale.

Total Sale = 'MiAguila Database'[Base Price]*'MiAguila Database'[Quantity delivered]

Pregunta PowerBi1.jpg

2. I subsequently created a measure called "Sale"

Sale = SUM('MyAguila Database'[Total Sale])

Pregunta PowerBi2.png

Hi @Syndicate_Admin 

 

Good Night😉

Try this measure:

 

Previous Month Sale  =
VAR _T =
    TODAY ()//or any date 
VAR _Y =
    YEAR ( _T )
VAR _M =
    MONTH ( _T )
VAR _LD =
    DATE ( _Y, _M, 1 ) - 1
VAR _FD =
    DATE ( _Y, _M - 1, 1 )
RETURN
    CALCULATE (
        [Sale],
        FILTER ( 'Calendar', 'Calendar'[Date] <= _LD && 'Calendar'[Date] >= _FD )
    )

 

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

Appreciate your Kudos!!

Thank you very much, the formula worked for me, although the novelty I have is that when filtering by month I would be gusaria to show me the sales of the month anteror of the filtering.

In this case I filtered by "Julio", I would be told to bring me the sales of "June".

pREGUNTA pOWERbI3.jpg

Hi @Syndicate_Admin 

 

In the previous code rather than 

VAR _T =
    TODAY ()

use SELECTEDVALUE.

 

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

Appreciate your Kudos!!

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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