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
DebbieE
Community Champion
Community Champion

Struggling with Current and Same period Last year only working without a date in the visual

really struggling (Still with time based intellicege

 

I have total Persons which is basically a distinct ount of people ID

 

And I have People this snapshot

In the date table I have a flag against the latest snapshot date used and then my dax is 

 

No People Latest Census = CALCULATE (
   [Total People],
    'Fact','Dim Date ('[latest Snapshot] = 1)
 
And I have a Same Period Last Year 
No People Same Period Last Year = CALCULATE([Total People]
                                            ,SAMEPERIODLASTYEAR('Dim Date'[Date])
                                    )
 
I eventually want a measure showing the difference between current and last period
 
[No People Latest Census] - [No People Same Period Last Year]
 And i want to display this in a visual
 
However. When i add a table like this everything is fine
 
date              Total People    Lastest Period   Last Period   Difference
01/01/22       100
01/01/23       150                            150             100                50
 
But withough the date I get this
Latest  Period   last Period Difference
 150                    250            100                
 
And Basically in the visual I only want to show the difference and Last period is just summing everything up without the Date in here
 
How do you deal with SAMEPERIODLAST year when your visual cant hold the actual date in it? Im really struggling with the concepts behind this?
 
Im essentially wanting a chart to just show changes
 
1 ACCEPTED SOLUTION
SEMattis
Advocate II
Advocate II

@DebbieE, the reason why you are struggling is that you have to think of the context in which SAMEPERIODLAST is operating. When you remove the date column the measure in which you apply the SAMEPERIODLAST looses track of context and then sums all rows of your data in the last period, hence the 150 (Latest period) + 100 (Previous Period).

 

If you want to compare the date of your most recent snapshot to the same period the previous year you could also 

try something like this: 

 

VAR LYear = CALCULATE(MAX('Dim Date'[Date]) - 365, '[latest Snapshot] = 1')

 

Then add the variable to your filter in the calculate function under the RETURN statement as follows:

 

RETURN

 CALCULATE([Total People]
                                            ,'Dim Date'[Date] = LYear
                                    )

Hopefully it gives you what you want, though it is a bit hard coded.

View solution in original post

3 REPLIES 3
SEMattis
Advocate II
Advocate II

@DebbieE, the reason why you are struggling is that you have to think of the context in which SAMEPERIODLAST is operating. When you remove the date column the measure in which you apply the SAMEPERIODLAST looses track of context and then sums all rows of your data in the last period, hence the 150 (Latest period) + 100 (Previous Period).

 

If you want to compare the date of your most recent snapshot to the same period the previous year you could also 

try something like this: 

 

VAR LYear = CALCULATE(MAX('Dim Date'[Date]) - 365, '[latest Snapshot] = 1')

 

Then add the variable to your filter in the calculate function under the RETURN statement as follows:

 

RETURN

 CALCULATE([Total People]
                                            ,'Dim Date'[Date] = LYear
                                    )

Hopefully it gives you what you want, though it is a bit hard coded.

DebbieE
Community Champion
Community Champion

I have gone for Flags in the Date Dimenion for this specific issue. 

 

Thanks for that

No problem at all.

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.