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 have a question about data modelling and/or DAX query.
Below can be found a simplified data model. This model is built in Excel (Power Pivot).
There is a Transactions table that is a fact table holding data from an accounting system.
The are also two tables (Areas and ConversionFactors) that currently have no relationships to any other tables.
What I need to do is create a report showing for every SegmentID and a finance year a margin amount calculated as follows:
multiplied by
divided by
However I’m not sure how to calculate such an amount. I’ve tried using NATURALLEFTOUTERJOIN to create a temporary (VAR) table by joining Areas and ConversionFactors however there were two issues with that. Firstly, I was only able to join it by one column whereas here they need to be joined by Year and SegmentID. Secondly, I didn’t seem to be able to filter that temporary table to only get values for a current SegmentID.
Any ideas/suggestions will be much appreciated.
Kind regards,
Solved! Go to Solution.
I would consider merging Areas and ConversionFactors into Transactions, so you have SegmentArea and ConversionFactor as columns in that table.
Then you could write something like this (untested):
VAR _Summary_ =
CALCULATETABLE (
SUMMARIZE (
Transactions,
Transactions[SegmentID],
Transactions[SegmentArea],
Transactions[ConversionFactor],
"@SumValue", SUM ( Transactions[Value] )
),
ALL ( Segments )
)
VAR _CurrSubtable_ =
FILTER ( _Summary_, Transactions[SegmentID] IN VALUES ( Segments[SegmentID] ) )
RETURN
DIVIDE (
SUMX ( _CurrSubtable_, [@SumValue] * [SegmentArea] * [ConversionFactor] ),
SUMX ( _Summary_, [@SumValue] * [SegmentArea] * [ConversionFactor] )
)
I would consider merging Areas and ConversionFactors into Transactions, so you have SegmentArea and ConversionFactor as columns in that table.
Then you could write something like this (untested):
VAR _Summary_ =
CALCULATETABLE (
SUMMARIZE (
Transactions,
Transactions[SegmentID],
Transactions[SegmentArea],
Transactions[ConversionFactor],
"@SumValue", SUM ( Transactions[Value] )
),
ALL ( Segments )
)
VAR _CurrSubtable_ =
FILTER ( _Summary_, Transactions[SegmentID] IN VALUES ( Segments[SegmentID] ) )
RETURN
DIVIDE (
SUMX ( _CurrSubtable_, [@SumValue] * [SegmentArea] * [ConversionFactor] ),
SUMX ( _Summary_, [@SumValue] * [SegmentArea] * [ConversionFactor] )
)
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
25 | |
10 | |
7 | |
6 | |
6 |
User | Count |
---|---|
30 | |
11 | |
11 | |
10 | |
6 |