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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
H3nning
Helper V
Helper V

Previous Period as single Value

Hi,

 

Im experimenting with SCD2 data and I have a problem with a time intelligence related calculation. To keep it simple Id rather not explain the whole complexity of the context.

 

I have a table with dates. Pretty much self explanatory, every day in one row. There are no relations to other tables.

 

In a calculation i need to get the dynamic minimum of the date table in a hierarchy. 

For example i build a column chart and bring the date on the x-Axis. Then dependend on the drill down level I built a variable with the minimum date:

VAR MINDATE = MIN(Date[Date])

 

So if Im on Month level the MINDATE in the August Slice would be "2023-08-01".

 

Now I need a second Date which represents the minimum of the previous period depending on the drill down level. So if im on month the PREVDATE in the August Slice would be "2023-07-01".

 

And now important:

if I drill down to days the values for the 1st of August would be

MINDATE=2023-08-01

PREVDATE=2023-07-31 <- so now it is not one month before, but one day, because of day drill-level!

 

If Im on the quarter Level it should also adapt. Values for Q3:

MINDATE = 2023-07-01

PREVDATE = 2023-04-01

 

Same with years, i think the pattern is clear now.

 

Any ideas how to achieve this. Perfect would be how to calculate a variable in a measure. VAR PREVDATE = ?

 

Thanks in advance 🙂 

3 REPLIES 3
some_bih
Community Champion
Community Champion

Hi @H3nning as you are on beginning of your project, I suggest to check link about different date calculation in DAX.

Find your scenario, it could be MTD, PMC, PM some other concerning months. Benefit of this solution is that in future you can easly adopt rest of time intelligence calculation which currently you do not need. 

Did I answer correctly? Kudos appreciate / accept solution.

Link: https://www.daxpatterns.com/standard-time-related-calculations/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Hi, thank you, but I couldn't find a solution there. I tried two approaches. With ISINSCOPE it seems it does not work with an automatic hierarchy. My resultset is always empty. I used

SWITCH(TRUE,

   ISINSCOPE(Date.Day), ~Calculation for day level~

   ,ISINSCOPE(Date.Month), ~Calculation for month level~

   ,ISINSCOPE(Date.Quarter), ~Calculation for quarter level~

   ,ISINSCOPE(Date.Year), ~Calculation for year level~

 

The result is always empty, although i tested the calculation for month level and it is correct. But even on month level it looks like this:

H3nning_0-1692597216256.png

 

 

The other thing I thought about is PARALLELPERIOD, but the issue with that is, that it returns a table of dates. But I need a single value to compare it to my SCD2 data. MIN(PARALLELPERIOD()) is also not possible, because MIN requires a column, not a table.

some_bih
Community Champion
Community Champion

Hi @H3nning I usually find my scenario on link from SQLBI.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.