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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mrklucz
Regular Visitor

Relative time measures with Dynamic Time axis

Hi,

 

I'm having an issue with a measure with relative time period.

 

My model is having dateTable and factTable with a relationship.

 

My measure looks like:

Measure= 
VAR CurrentMonth =    
CALCULATE(
    SUM(factTable[Actual])
)
VAR SamePeriodPreviousYear =
CALCULATE(
    SUM(factTable[Actual]),
    SAMEPERIODLASTYEAR(dateTable[Date])
   )

RETURN
DIVIDE(
	CurrentMonth-SamePeriodPreviousYear,
	SamePeriodPreviousYear)

There is a requirement to provide a table with dynamically changing to Months/Quarters/Years

 

I created additional table with dates which contains Date, DatePart, DateDisplay, Order - as A result I got a table with all 

potential dates, dateparts and display dates- and created a relationship to dateTable many-to-one in both directions.

 

I created a matrix table:

- in rows I have my KPIs

- in columns I have my Date display (from calculated table)

- values (my Actuals)

 

All is good when I'm using simple measures with no time-intelligence functions. Quarters/Months/Years are chaninging dynamically and present a proper data, but I have an issue that my measure for sameperiodlastyear doesn't work at all and present blanks. 

 

Additionaly, this model is used for multiple other reports - so changing the formula is not an option, as this would need to get through a whole uat and approval processes. This dynamically changing time axis (column) is a requirement for only this report.

 

How can I overcome this?

1 ACCEPTED SOLUTION

@amitchandak it was not an option since I'm using a live connection to AAS, but I managed to resolve this issue. 

 

I created a table 'DatesWithPartsYear' that combines dates, DisplayDates, PartOfYear as a seperate table (no connection to the model) and then re-caluclated my measure for this report to.

 

In DateTable I created additional columns "Year Month" and "Year Quarter" - to follow the same data schema as in DatesWithPartsYear. then in my measers I added TREATAS - to treat my displayDate as a specific column from ch_date depends on context ot PartYear.

 

 

 

Actual = 
SWITCH(
    VALUES ( DatesWithPartsYear[PartYear] ),
    "Month",
        CALCULATE(
            SUM(factTable[Value]),
            factTable[MeasureTypeName] = "Actual",
            TREATAS ( VALUES ( v_DatesWithPartsYear[DisplayDate] ) , dateTable[Year Month])
        ),
    "Quarter",
        CALCULATE(
            SUM(factTable[Value]),
            factTable[MeasureTypeName] = "Actual",
            TREATAS ( VALUES ( DatesWithPartsYear[DisplayDate] ) , dateTable[Year Quarter])
        )
    )

 

 

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@mrklucz , You can use field parameters 

 

Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...
Power BI Field Parameters- Measure Slicer and Axis/Dimension slicer: https://youtu.be/lqF3Wa1FllE
Switch TOPN with Field Parameters: https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak it was not an option since I'm using a live connection to AAS, but I managed to resolve this issue. 

 

I created a table 'DatesWithPartsYear' that combines dates, DisplayDates, PartOfYear as a seperate table (no connection to the model) and then re-caluclated my measure for this report to.

 

In DateTable I created additional columns "Year Month" and "Year Quarter" - to follow the same data schema as in DatesWithPartsYear. then in my measers I added TREATAS - to treat my displayDate as a specific column from ch_date depends on context ot PartYear.

 

 

 

Actual = 
SWITCH(
    VALUES ( DatesWithPartsYear[PartYear] ),
    "Month",
        CALCULATE(
            SUM(factTable[Value]),
            factTable[MeasureTypeName] = "Actual",
            TREATAS ( VALUES ( v_DatesWithPartsYear[DisplayDate] ) , dateTable[Year Month])
        ),
    "Quarter",
        CALCULATE(
            SUM(factTable[Value]),
            factTable[MeasureTypeName] = "Actual",
            TREATAS ( VALUES ( DatesWithPartsYear[DisplayDate] ) , dateTable[Year Quarter])
        )
    )

 

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.