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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
c0rp
New Member

Current month value calculated for the current year and last years

Hello there,

im trying to calculate the Value of a KPI for the current Month (Sep. 2022) and dynamicly for the same months of the previous years. this behavoir should be in the Year hierachy only, else it should just represent the value of the month. (so on the month Hierachy the Values stay like the Image)

c0rp_0-1662995290712.png

 

Result should look like this:

Measure Last Month20212022
EBIT1621
Margin1345
Staffloss7579


https://drive.google.com/file/d/1Pm-aVU1yzisKmxRfC9BF1nVGARjbgdXI/view?usp=sharing 

So Far i didnt manage to get the Results with sameperiodlast year... 
Thank you for the Help!

2 REPLIES 2
c0rp
New Member

i tried your solution, its not working for me. could you please implement it in the sample file?

var lastdate_ = CALCULATE (
    MAX ( 'Fact'[Date] ),
    FILTER (
        ALL(Fact'),
        [KPI] = MAX( 'Fact'[KPI])
            && NOT('Fact'[KPI]=0)
    )
)

this Measure returns the last Valuedate, i need this date for the previous Year.
but Sameperiodlastyear or Previuosyear are not wokring for me.

amitchandak
Super User
Super User

@c0rp ,with SAMEPERIODLASTYEAR using a date table marked as date table you can get last year data. But you can not get last year date and column, you will only get that under this year's column under a new measure, like the second table (but a new measure)

 

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

 

for that display, you should consider the calculation group

 

Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display : https://youtu.be/qMNv67P8Go0

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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