Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi
I'm looking a DAX formula that allows me to compare a quarter from 2 different years, so I can show the increase or decrease in %
Any ideas to a useful DAX formula?
Solved! Go to Solution.
Hi @SteenSoernesen ,
Thanks for your follow-up. Since your dataset contains only Year, Quarter, and Passenger Count (without a full date column), you can still achieve a year-over-year quarter comparison by adding a calculated column to extract the numeric quarter and using measures to calculate the % change.Here's a step by step approach:
Assuming the data table name is PassengerData
1. Create a numeric quarter column to convert "1. Kvartal" to 1, and so on:
QuarterNumber =
Also, to Format % Change vs Last Year Same Quarter as percentage: Go to Model view --> select the measure --> Format as Percentage with 1 decimal place.
You can also apply conditional formatting to the % change measure to highlight increases and decreases.
Hope this helps. Please reach out for further assistance.
If this post helps, then please consider to give a kudos and Accept as the solution to help the other members find it more quickly.
Thank you.
Looking at the incoming data. I don't have a date Column I can use.
I only have a quarter and year Columns
Hi @SteenSoernesen ,
Thanks for your follow-up. Since your dataset contains only Year, Quarter, and Passenger Count (without a full date column), you can still achieve a year-over-year quarter comparison by adding a calculated column to extract the numeric quarter and using measures to calculate the % change.Here's a step by step approach:
Assuming the data table name is PassengerData
1. Create a numeric quarter column to convert "1. Kvartal" to 1, and so on:
QuarterNumber =
Also, to Format % Change vs Last Year Same Quarter as percentage: Go to Model view --> select the measure --> Format as Percentage with 1 decimal place.
You can also apply conditional formatting to the % change measure to highlight increases and decreases.
Hope this helps. Please reach out for further assistance.
If this post helps, then please consider to give a kudos and Accept as the solution to help the other members find it more quickly.
Thank you.
Hi @SteenSoernesen ,
Following up to see if your query has been resolved. If any of the responses helped, please consider marking the relevant reply as the 'Accepted Solution' to assist others with similar questions.
If you're still facing issues, feel free to reach out.
Thank you.
Hi @SteenSoernesen ,
Thanks for using Microsoft Fabric Community.
Just checking in to see if you query is resolved and if any responses were helpful. If so, kindly consider marking the helpful reply as 'Accepted Solution' to help others with similar queries.
Otherwise, feel free to reach out for further assistance.
Thank you.
Also thanks to @sjoerdvn and @anilelmastasi for your prompt responses.
Assuming you have a measure [Sales], a date table 'Calendar' with a date column 'date' and a column that has the quarter info. If you then filter on one year and quarter, you can use the measure below to get the change from the same quarter the previous year.
change from same quarter previous year =
VAR cq = [Sales]
VAR pq = CALCULATE([Sales], PARALLELPERIOD(Calendar[Date],-4,quarter))
RETURN DIVIDE(cq - pq,pq,0)
If you want to calculate it manually, you can simply use:
Sales CY Quarter =
CALCULATE(
[Total Sales],
FILTER(
ALL('Date'),
'Date'[Year] = MAX('Date'[Year]) &&
'Date'[Quarter] = MAX('Date'[Quarter])
)
)
But I suggest you to this dynmically if possible:
Create a “Years Ago” parameter
Go to Modeling → New Parameter → Numeric Range.
Set:
Name → Years Ago
Minimum → 1
Maximum → 5 (or whatever range you want)
Increment → 1
This will create a table called Years Ago and a slicer that users can control on the report.
Create the dynamic comparison measure
Sales N Years Ago Quarter =
VAR SelectedYearsAgo = SELECTEDVALUE('Years Ago'[Years Ago])
VAR CurrentYear = MAX('Date'[Year])
VAR CurrentQuarter = MAX('Date'[Quarter])
RETURN
CALCULATE(
[Total Sales],
FILTER(
ALL('Date'),
'Date'[Year] = CurrentYear - SelectedYearsAgo &&
'Date'[Quarter] = CurrentQuarter
)
)
Create the % change measure
% Change vs N Years Ago =
DIVIDE(
[Total Sales] - [Sales N Years Ago Quarter],
[Sales N Years Ago Quarter],
0
)
If this solved your issue, please mark it as the accepted solution. ✅
User | Count |
---|---|
17 | |
14 | |
14 | |
13 | |
12 |
User | Count |
---|---|
19 | |
15 | |
15 | |
11 | |
10 |