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
Anonymous
Not applicable

Comparing today value vs last day of the past month

Hi,

 

How can I compare todays value vs last day of the past month. For example, the percentage variation in a given time series value from last day of the past month (9/30/2019) against today (10/28/2019).

 

This is specifically to calculate the depreciation and appreciation of a currency over time.

 

Thanks in advance,

 

Ivan

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Anonymous 

Please always show a sample of your data model. Otherwise we have to guess, give a general answer and it's inefficient.

Please read through these posting tips (particularly the bits in red). By following them, you will increase the probability of getting your questions answered quickly and you will make things much easier for people trying to help.

 

You could create a measure and place it in a card visual:

Measure =
VAR TodayVal_ =
    CALCULATE (
        DISTINCT ( Table1[Value] ),
        FILTER ( ALL ( Table1[Date] ), Table1[Date] = TODAY () )
    )
VAR PreviousMonthVal_ =
    CALCULATE (
        DISTINCT ( Table1[Value] ),
        FILTER ( ALL ( Table1[Date] ), Table1[Date] = EOMONTH ( TODAY (), -1 ) )
    )
RETURN
    TodayVal_ - PreviousMonthVal_ //Simple subtraction. Change this to the operation that you need

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

View solution in original post

5 REPLIES 5
AlB
Super User
Super User

Hi @Anonymous 

Please always show a sample of your data model. Otherwise we have to guess, give a general answer and it's inefficient.

Please read through these posting tips (particularly the bits in red). By following them, you will increase the probability of getting your questions answered quickly and you will make things much easier for people trying to help.

 

You could create a measure and place it in a card visual:

Measure =
VAR TodayVal_ =
    CALCULATE (
        DISTINCT ( Table1[Value] ),
        FILTER ( ALL ( Table1[Date] ), Table1[Date] = TODAY () )
    )
VAR PreviousMonthVal_ =
    CALCULATE (
        DISTINCT ( Table1[Value] ),
        FILTER ( ALL ( Table1[Date] ), Table1[Date] = EOMONTH ( TODAY (), -1 ) )
    )
RETURN
    TodayVal_ - PreviousMonthVal_ //Simple subtraction. Change this to the operation that you need

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

Anonymous
Not applicable

Actually, it didn't work. 

 
 

image.png

 

It is returning all zeroes.

Anonymous
Not applicable

Thanks for the answer.

 

Also, if i would like to get the value for the end of last year, is there also a function?

@Anonymous 

If you want the 31st of December of the previous year, you could do:

 

Measure =
VAR TodayVal_ =
    CALCULATE (
        DISTINCT ( Table1[Value] ),
        FILTER ( ALL ( Table1[Date] ), Table1[Date] = TODAY () )
    )
VAR LastDayPreviousYearVal_ =
    CALCULATE (
        DISTINCT ( Table1[Value] ),
        FILTER (
            ALL ( Table1[Date] ),
            Table1[Date] = DATE ( YEAR ( TODAY () ) - 1, 12, 31 )
        )
    )
RETURN
    TodayVal_ - LastDayPreviousYearVal_ //Simple subtraction. Change to the operation you need

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

 

Anonymous
Not applicable

Maybe December 31st wont be the last working day. It could be a holiday or a sunday, so I would prefer a code that selects the last day available. Is this possible?

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.