Creating a Linear Gauge with Multiple Targets in Power BI
Ghassen Khammouma ????
Analytics Engineer Certified | Data Manager | J'aide mes clients à gérer et à présenter efficacement leurs données à l'aide de la gouvernance et de la visualisation des données.
Have you ever wondered if it’s possible to have a linear gauge with not just one, but two target lines?? Recently while discussing with someone this question came up and I found the idea intriguing and started visualizing how this feature could enhance data visualization. To my surprise when I researched on this feature, I barely found any content addressing this topic. So, here I am, sharing some of my insights on creating a linear gauge with multiple targets.
In this article, we’ll explore three important questions about the gauge with multiple targets:
Let's start with the topic.
Why It’s Helpful
Here are the reasons why Actual and Target comparisons are helpful and the role of multiple targets.
When Do We Need It?
The previous section talked about why a Gauge is helpful. Let's dig in more and find out the specific cases where 2 targets are helpful.
How to Create One in Power BI Bar Chart?
I didn't find any radial or linear gauge that offers this feature. So I decided to re-create something similar using the Power BI Bar chart. Follow these step-by-step guides.
Step-by-Step Guide
领英推荐
Total Sale = SUM(Orders[Sales])
Total Cost = [Total Sale] - [Total Profit]
Sale LM = CALCULATE([Total Sale], DATEADD('Order Dates'[Date], -1, MONTH))
Remaining = [MaxPoint] - SUM(Orders[Sales])
MaxPoint = MAXX(VALUES('Order Dates'[Month Name]), MAX([Total Sale], [Sale LM])) * 1.2
2. Create a Stacked Bar Chart:
3. Add Reference Lines for Targets:
4. Format and Style: Customize the chart’s appearance:
5. Enhance Tooltip Readability: Create a tooltip measure (e.g., PY Tooltip) to display relevant information:
PY Tooltip=
VAR __T1 = [Total Cost]
VAR __T2 = [Total Sale]
VAR __T3 = __T2 - __T1
VAR __P1 = DIVIDE(__T3,__T2)
VAR __P1Color =
IF(__P1 > 0,
" ?", // up arrow
" ?" // down arrow
)
VAR __R1 = FORMAT(__T1, "$0,K") & " | " & FORMAT(__P1, "+0%") & __P1Color
RETURN __R1
Target Tooltip =
VAR __T2 = [Total Sale]
VAR __P2 = [Variance Sale LM %]
VAR __P2Color =
IF(__P2 > 0,
" ?", // up arrow
" ?" // down arrow
)
VAR __V2 =
IF(__P2 > 0,
FORMAT([Variance Sale LM %], "+0%"),
FORMAT([Variance Sale LM %], "0%")
)
VAR __R2 = FORMAT([Sale LM], "$0,K") & " | " & __V2 & __P2Color
RETURN __R2
6. Review and Refine: Compare your result with the expected outcome. Adjust styling as need
By following these steps, you’ll have a linear gauge with two target lines, providing richer insights into your data.
I hope these DAX and information are helpful.
Senior Business Data Analyst at Saudi Aramco...talk to me about #dataanlytics #dataengineering #data visualization #ETL
1 个月the step to add legends is unclear.
?? Directeur de projets ITSM/ESM & Transformation Digitale | AI & Innovation ?? | Expert PowerBI ??
1 年Merci pour l’astuce Ghassen Khammouma ???? ????