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.
I have two tables seperate tables shown below. An expense table and a revenue table. Both tables have a relationship based on the circuit column. I would like to create a measure that calculates the total Revenue when
Expense does not = 0
and Max Month = December
and Min Month = January
and Identifier = Y
Expense Table
| |||
Circuit | Min Month | Max Month | Expense |
A | January | December | 0 |
B | January | January | 10 |
C | January | December | 0 |
D | January | December | 20 |
E | April | June | 0 |
F | April | December | 40 |
G | April | December | 50 |
H | January | April | 10 |
I | January | May | 20 |
J | January | December | 30 |
K | January | December | 40 |
L | January | July | 50 |
M | January | December | 40 |
Revenue Table | ||
Circuit | Revenue | Identifier |
A | 100 | Y |
B | 120 | Y |
C | 200 | Y |
D | 300 | Y |
E | 80 | Y |
F | 100 | Y |
G | 20 | Y |
H | 40 | Y |
I | 60 | Y |
J | 100 | Y |
K | 200 | Y |
L | 20 | Y |
Solved! Go to Solution.
@dw700d Well, that makes a big difference. Try this:
Measure =
VAR __Table = FILTER('Expense', [Expense] <> 0 && 'Expense'[Max Month] = "December" && 'Expense'[Min Month] = "January")
VAR __Circuits = DISTINCT(SELECTCOLUMNS(__Table, "__Circuits", [Circuit]))
VAR __Result = SUMX(FILTER('Revenue', [Identifier] = "Y" && [Circuit] IN __Circuits),[Revenue])
RETURN
__Result
@dw700d Try:
Measure =
VAR __Table = FILTER( 'Revenue', [Identifier] = "Y" && RELATED(Expense[Expense]) <> 0 && RELATED(Expense[Max Month]) = "December" && RELATED(Expense[Min Month]) = "January")
VAR __Result = SUMX(__Table, [Revenue])
RETURN
__Result
@Greg_Deckler thank you. When I enter the related function intellisense does not give me an option to select a column. The revenue table has unique values and the expense table is the many side of the relationship. Maybe thats why but I am not sure. Any other thoughts?
@dw700d Well, that makes a big difference. Try this:
Measure =
VAR __Table = FILTER('Expense', [Expense] <> 0 && 'Expense'[Max Month] = "December" && 'Expense'[Min Month] = "January")
VAR __Circuits = DISTINCT(SELECTCOLUMNS(__Table, "__Circuits", [Circuit]))
VAR __Result = SUMX(FILTER('Revenue', [Identifier] = "Y" && [Circuit] IN __Circuits),[Revenue])
RETURN
__Result
Hello @dw700d ,
You can try the below solution. Please upvote if it works for you.
Total Revenue = CALCULATE( SUM(Revenue[Revenue]), Expense[Expense] <> 0, Revenue[Identifier] = "Y", DATESBETWEEN( Revenue[Circuit], FILTER( Expense, Expense[Min Month] = "January" ), FILTER( Expense, Expense[Max Month] = "December" ) ) )
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
81 | |
75 | |
60 | |
37 | |
33 |
User | Count |
---|---|
102 | |
56 | |
52 | |
45 | |
40 |