Forum Discussion
Conditional Quadrants in Bubble Chart-PBI
- 10 months ago
Okay AartiD,
The reason could be One (or both) of your measures is using DAX time-intelligence function (like DATEADD, SAMEPERIODLASTYEAR, PARALLELPERIOD, etc.
Create a date table if uou've not created one
Date_Master =
ADDCOLUMNS(
CALENDAR(DATE(2020,1,1), DATE(2030,12,31)),
"Year", YEAR([Date]),
"Month", FORMAT([Date], "MMM"),
"Month-Year", FORMAT([Date], "MMM YYYY"),
"Quarter", "Q" & FORMAT([Date], "Q")
)Go to Model view → Table tools → Mark as date table → Select [Date] column.
Ensure your fact table (e.g., Sales) has a relationship with Date table
Rebuild your measures like below
3-month rolling average (QoQ)
QoQ Growth (Rolling Avg 3M) % :=
VAR CurrentSales =
AVERAGEX(
DATESINPERIOD('Date_Master'[Date], MAX('Date_Master'[Date]), -3, MONTH),
[Total Sales]
)
VAR PrevSales =
AVERAGEX(
DATESINPERIOD('Date_Master'[Date], DATEADD(MAX('Date_Master'[Date]), -3, MONTH), -3, MONTH),
[Total Sales]
)
RETURN
DIVIDE(CurrentSales - PrevSales, PrevSales, 0) * 1006-month rolling average (HYoHY)
HYoHY Growth (Rolling Avg 6M) % :=
VAR CurrentSales =
AVERAGEX(
DATESINPERIOD('Date_Master'[Date], MAX('Date_Master'[Date]), -6, MONTH),
[Total Sales]
)
VAR PrevSales =
AVERAGEX(
DATESINPERIOD('Date_Master'[Date], DATEADD(MAX('Date_Master'[Date]), -6, MONTH), -6, MONTH),
[Total Sales]
)
RETURN
DIVIDE(CurrentSales - PrevSales, PrevSales, 0) * 100Now use these measures in final DAX
Quadrant Category :=
SWITCH(
TRUE(),
[QoQ Growth (Rolling Avg 3M) %] > 0 &&
[HYoHY Growth (Rolling Avg 6M) %] > 0 &&
[QoQ Growth (Rolling Avg 3M) %] >= 10 &&
[QoQ Growth (Rolling Avg 3M) %] > [HYoHY Growth (Rolling Avg 6M) %], "Good",[QoQ Growth (Rolling Avg 3M) %] > [HYoHY Growth (Rolling Avg 6M) %], "Improving",
[QoQ Growth (Rolling Avg 3M) %] < 0 &&
[HYoHY Growth (Rolling Avg 6M) %] < 0 &&
[QoQ Growth (Rolling Avg 3M) %] < -10 &&
[QoQ Growth (Rolling Avg 3M) %] < [HYoHY Growth (Rolling Avg 6M) %], "Concern",[QoQ Growth (Rolling Avg 3M) %] < [HYoHY Growth (Rolling Avg 6M) %], "Watch Out",
"Other"
)Use in the view
-
X-Axis: [QoQ Growth (Rolling Avg 3M) %]
-
Y-Axis: [HYoHY Growth (Rolling Avg 6M) %]
-
Size: [Total Sales]
-
Legend: [Quadrant Category]
-
Details: Hospital Name
-
I am getting below error while using above formula.
" Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."
Okay AartiD,
The reason could be One (or both) of your measures is using DAX time-intelligence function (like DATEADD, SAMEPERIODLASTYEAR, PARALLELPERIOD, etc.
Create a date table if uou've not created one
Date_Master =
ADDCOLUMNS(
CALENDAR(DATE(2020,1,1), DATE(2030,12,31)),
"Year", YEAR([Date]),
"Month", FORMAT([Date], "MMM"),
"Month-Year", FORMAT([Date], "MMM YYYY"),
"Quarter", "Q" & FORMAT([Date], "Q")
)
Go to Model view → Table tools → Mark as date table → Select [Date] column.
Ensure your fact table (e.g., Sales) has a relationship with Date table
Rebuild your measures like below
3-month rolling average (QoQ)
QoQ Growth (Rolling Avg 3M) % :=
VAR CurrentSales =
AVERAGEX(
DATESINPERIOD('Date_Master'[Date], MAX('Date_Master'[Date]), -3, MONTH),
[Total Sales]
)
VAR PrevSales =
AVERAGEX(
DATESINPERIOD('Date_Master'[Date], DATEADD(MAX('Date_Master'[Date]), -3, MONTH), -3, MONTH),
[Total Sales]
)
RETURN
DIVIDE(CurrentSales - PrevSales, PrevSales, 0) * 100
6-month rolling average (HYoHY)
HYoHY Growth (Rolling Avg 6M) % :=
VAR CurrentSales =
AVERAGEX(
DATESINPERIOD('Date_Master'[Date], MAX('Date_Master'[Date]), -6, MONTH),
[Total Sales]
)
VAR PrevSales =
AVERAGEX(
DATESINPERIOD('Date_Master'[Date], DATEADD(MAX('Date_Master'[Date]), -6, MONTH), -6, MONTH),
[Total Sales]
)
RETURN
DIVIDE(CurrentSales - PrevSales, PrevSales, 0) * 100
Now use these measures in final DAX
Quadrant Category :=
SWITCH(
TRUE(),
[QoQ Growth (Rolling Avg 3M) %] > 0 &&
[HYoHY Growth (Rolling Avg 6M) %] > 0 &&
[QoQ Growth (Rolling Avg 3M) %] >= 10 &&
[QoQ Growth (Rolling Avg 3M) %] > [HYoHY Growth (Rolling Avg 6M) %], "Good",
[QoQ Growth (Rolling Avg 3M) %] > [HYoHY Growth (Rolling Avg 6M) %], "Improving",
[QoQ Growth (Rolling Avg 3M) %] < 0 &&
[HYoHY Growth (Rolling Avg 6M) %] < 0 &&
[QoQ Growth (Rolling Avg 3M) %] < -10 &&
[QoQ Growth (Rolling Avg 3M) %] < [HYoHY Growth (Rolling Avg 6M) %], "Concern",
[QoQ Growth (Rolling Avg 3M) %] < [HYoHY Growth (Rolling Avg 6M) %], "Watch Out",
"Other"
)
Use in the view
-
X-Axis: [QoQ Growth (Rolling Avg 3M) %]
-
Y-Axis: [HYoHY Growth (Rolling Avg 6M) %]
-
Size: [Total Sales]
-
Legend: [Quadrant Category]
-
Details: Hospital Name