cancel
Showing results 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.

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 = ?

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.

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.

Proud to be a Super User!

Announcements

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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors