Just a quick post on something that I recently had to remember how to do and thought would be useful to write down and share.
The Problem
I have a dataset which duplicates some values, something like this:
Here I’ve got two product lines that each have two narratives associated with them. I am required to SUM the price column for a totals rows in a table displaying the product lines, so that I get an output in my report something like this:
By default, SSRS will use a SUM expression for the ‘Price’ column (SUM(Fields!Price.Value)), but in this instance it will give the wrong answers (21.00, 41.98, 62.98) because the product lines are being doubled up by their narratives. Ordinarily you might break the narratives out into their own data set, but sometimes that is not possible. So how do I get the correct answer?
The Solution
The expressions in the ‘Price’ column should be set to:
=SUM(IIF(Fields!NarrativeNum.Value = 1, Fields!Price.Value, 0))
This expression checks for the value of NarrativeNum on the current row and only SUMs the Price value if NarrativeNum == 1, otherwise we substitute a 0. In effect, the SUM sees our dataset like this:
Summary
We’ve seen how we can use a combination of functions to prevent SSRS from counting duplicate values. This is a simple technique but can be very useful.
Pareto Charts in Power BI and the DAX behind them
The Pareto principle, commonly referred to as the 80/20 rule, is a concept of prioritisation.
Apr
Databricks: Cluster Configuration
Databricks, a cloud-based platform for data engineering, offers several tools that can be used to
Apr
AI Assistance in Microsoft Fabric
The exponential growth of Large Language Models (LLMs) couples with Microsoft’s close partnership with OpenAI
Apr
10 reasons why it’s worth the effort to understand the value of your data
“If leaders really want to create a data driven culture, the journey starts with them!
Apr
Content Safety in Azure AI Studio
Azure AI Content Safety is a solution designed to identify harmful content, whether generated by
Apr
Model Benchmarks in Azure AI Studio
In the constantly changing field of artificial intelligence (AI) and machine learning (ML), choosing the
Apr
Celebrating International Women’s Day: from Classroom to Code
As we celebrate International Women’s Day, I want to share my journey of breaking stereotypes
Mar
Pretty Power BI – Adding Pagination to Bar Charts
Good User Experience (UX) design is crucial in enabling stakeholders to maximise the insights that
Feb