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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

HELP ME PLEASE

Hello, I need support with a problem.
I have the sum of 2019 sales per month, but I need to make a comparison with the sum of 2020 sales for the current month.
That is, if today is 10/8/2020, in my 2019 graph it should show the sum of sales per month but in the month of October it should only be added until 10/8/2019 and the rest of the months that continue to be calculated from normal way.
2019
|Month | Total sales |
| jan      |  xxxx |
| feb      |  xxxx |
| mar     |  xxxx |
| apr      |  xxxx |
| may    |  xxxx |
| jun      |  xxxx |
| jul       |  xxxx |
| ago     |  xxxx |
| set      |  xxxx |
| oct      |  xxxx |   ----> how to show total sales until 8th october 2019, the last months are calcutated from normal way
| nov     |  xxxx | 
| dec     |  xxxx |

2020
|Month | Total sales |
| jan      |  xxxx |
| feb      |  xxxx |
| mar     |  xxxx |
| apr      |  xxxx |
| may    |  xxxx |
| jun      |  xxxx |
| jul       |  xxxx |
| ago     |  xxxx | 
| set      |  xxxx |
| oct      |  xxxx |   --->    but this day is current date, for example 8th october 2020


1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1602493862691.png

Since today is October 12th, October 2019 will only calculate the value before the 12th.

 

Best regards,
Lionel Chen

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

3 REPLIES 3
DataZoe
Microsoft Employee
Microsoft Employee

@Anonymous Try this measure:

 

Sales Prev Year =
VAR _stopdate = today()
RETURN
    SUMX (
        'Date',
        CALCULATE (
            IF (
                SELECTEDVALUE ( 'Date'[Date] ) >= _stopdate,
                BLANK (),
                CALCULATE ( [Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
            )
        )
    )

 

EDIT: replaced LASTNONBLANK ( 'Date'[Date], [Sales] ) with TODAY(), as that lastnonblank() took out more data than intended.

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Anonymous
Not applicable

thanks @DataZoe  but I don't know

Hi @Anonymous ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1602493862691.png

Since today is October 12th, October 2019 will only calculate the value before the 12th.

 

Best regards,
Lionel Chen

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

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.