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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Resolver I

## 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
Super User

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.

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

Proud to be a Super User!

Resolver I

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:

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.

Super User

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

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors