Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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?
Solved! Go to 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])
)
)
@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
@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])
)
)
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
22 | |
7 | |
6 | |
6 | |
6 |
User | Count |
---|---|
27 | |
10 | |
10 | |
9 | |
6 |