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 dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello.
I am new to PBI and I am struggling to get some DAX measures right, and I believe my problem is in understanding the IF function. And maybe using Calculate correctly to filter the information.
My idea is to get a table like this and add two more columns with the Confirmed Revenue and the Revenue Total, that follow the bellow structure (the highlighted is the database name and after it is the field used):
I am using this FactTable in order to get the information, since I created a Type column to identify from which database the information came from:
The Dates FactTable used and the Posted table structure is shown bellow:
(the Posted table has the first day of the month as date, but it is irrelevant since we will use the month to group)
Can anyone help me write the two DAX measures for Confirmed Revenue and Revenue Total?
Help is much apreciated 🙂
Thanks in advance!
Solved! Go to Solution.
Hi @Anonymous ,
You can try this method:
Sample data:
New measures:
CONFIRMED REVENUE =
VAR _Staff =
CALCULATE (
SUM ( 'Fact Staffing forecast'[Revenue DKK] ),
FILTER (
'Fact Staffing forecast',
'Fact Staffing forecast'[Date].[Month] = SELECTEDVALUE ( 'DimDates'[Month] )
)
)
VAR _actual =
CALCULATE (
SUM ( 'Fact NAV actual month'[Revenue DKK] ),
FILTER (
'Fact NAV actual month',
'Fact NAV actual month'[Date].[Month] = SELECTEDVALUE ( 'DimDates'[Month] )
)
)
RETURN
IF (
SELECTEDVALUE ( 'DimDates'[Post] ) = "Yes",
0,
IF (
MAX ( 'DimDates'[Month Number] ) = MONTH ( TODAY () ),
_actual + _Staff,
_Staff
)
)
REVENUE TOTAL =
VAR _budget =
CALCULATE (
SUM ( 'Fact NAV budget'[Revenue DKK] ),
FILTER (
'Fact NAV budget',
'Fact NAV budget'[Date].[Month] = SELECTEDVALUE ( 'DimDates'[Month] )
)
)
RETURN
IF ( SELECTEDVALUE ( 'DimDates'[Post] ) = "Yes", _budget, [CONFIRMED REVENUE] )
The result is:
Hope this helps you.
Here is my PBIX file.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello.
Thank you so much for the help.
I have been trying to go through the code, but I feel that solution is more complicated than the required since all the tables are connected through the Date in the DimDates table. The sample Data model would be more like this:
And we want the ActualPL from the FactNAV Budget, I am so sorry for the error.
Could you please revise these and help me adapt the code above?
Hi @Anonymous ,
You can try this method:
Sample data:
New measures:
CONFIRMED REVENUE =
VAR _Staff =
CALCULATE (
SUM ( 'Fact Staffing forecast'[Revenue DKK] ),
FILTER (
'Fact Staffing forecast',
'Fact Staffing forecast'[Date].[Month] = SELECTEDVALUE ( 'DimDates'[Month] )
)
)
VAR _actual =
CALCULATE (
SUM ( 'Fact NAV actual month'[Revenue DKK] ),
FILTER (
'Fact NAV actual month',
'Fact NAV actual month'[Date].[Month] = SELECTEDVALUE ( 'DimDates'[Month] )
)
)
RETURN
IF (
SELECTEDVALUE ( 'DimDates'[Post] ) = "Yes",
0,
IF (
MAX ( 'DimDates'[Month Number] ) = MONTH ( TODAY () ),
_actual + _Staff,
_Staff
)
)
REVENUE TOTAL =
VAR _budget =
CALCULATE (
SUM ( 'Fact NAV budget'[Revenue DKK] ),
FILTER (
'Fact NAV budget',
'Fact NAV budget'[Date].[Month] = SELECTEDVALUE ( 'DimDates'[Month] )
)
)
RETURN
IF ( SELECTEDVALUE ( 'DimDates'[Post] ) = "Yes", _budget, [CONFIRMED REVENUE] )
The result is:
Hope this helps you.
Here is my PBIX file.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
23 | |
11 | |
10 | |
9 | |
8 |