Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi! I am trying to use SELECTEDVALUE to apply different measures. Basicaly Depending on the year and month selected and comparing them to TODAY(), it shows a real data (if it is past) and estimated data (if is future). It works only if I select ONE MONTH and ONE YEAR. So, how can I do it with more than one selection? I am using this kind of comparison:
VAR Real=
IF( DATE(SELECTEDVALUE(Dim_Calendar[CalendarYear]), SELECTEDVALUE(Dim_Calendar[CalendarMonth]),1) < DATE(YEAR(TODAY()), MONTH(TODAY()),1), [Measure for the past) )
VAR Estimated =
Solved! Go to Solution.
What I made finally was:
Remove all the references to a date in the measures of the calculations and create a new measure like this:
Project Resource Cost (Real + Estimated) =
VAR F_Mes= EOMONTH(TODAY(),-1)
VAR Fecha_Reales= CALCULATETABLE(Dim_Calendar, Dim_Calendar[DateKey] <= F_Mes, KEEPFILTERS(Dim_Calendar))
VAR Fecha_Estimadas= CALCULATETABLE(Dim_Calendar, Dim_Calendar[DateKey] > F_Mes, KEEPFILTERS(Dim_Calendar))
VAR Real = CALCULATE([Project Resource Cost (Real)], Fecha_Reales)
VAR Estimada = CALCULATE([Project Resource Cost (Estimated)] + [Project Resource Cost - Third Party (Estimated)], Fecha_Estimadas)
RETURN Real + Estimada
Besides, I separated the measure in several to organize the code better.
With this changes, it works!
Check my other related post: https://www.google.com/url?q=https://community.powerbi.com/t5/Desktop/Total-is-empty/m-p/1671463%23M...
Thanks for your help @amitchandak
What I made finally was:
Remove all the references to a date in the measures of the calculations and create a new measure like this:
Project Resource Cost (Real + Estimated) =
VAR F_Mes= EOMONTH(TODAY(),-1)
VAR Fecha_Reales= CALCULATETABLE(Dim_Calendar, Dim_Calendar[DateKey] <= F_Mes, KEEPFILTERS(Dim_Calendar))
VAR Fecha_Estimadas= CALCULATETABLE(Dim_Calendar, Dim_Calendar[DateKey] > F_Mes, KEEPFILTERS(Dim_Calendar))
VAR Real = CALCULATE([Project Resource Cost (Real)], Fecha_Reales)
VAR Estimada = CALCULATE([Project Resource Cost (Estimated)] + [Project Resource Cost - Third Party (Estimated)], Fecha_Estimadas)
RETURN Real + Estimada
Besides, I separated the measure in several to organize the code better.
With this changes, it works!
Check my other related post: https://www.google.com/url?q=https://community.powerbi.com/t5/Desktop/Total-is-empty/m-p/1671463%23M...
Thanks for your help @amitchandak
@MacarenaGB ,The information you have provided is not making the problem clear to me. Can you please explain with an example.
Appreciate your Kudos.
Hi!
The issue is related to other of my posts (https://community.powerbi.com/t5/Desktop/Total-is-empty/m-p/1660101#M664024) so let my copy the whole measure
Project Resource (Real + Estimated) =
// If the month has already expired, the Effort Tracking data is used, choosing between
// Real Cost and Average Cost with a slicer
VAR Real_Resources =
CALCULATE(
[Project Resource Cost],
'Fact_Projects Billing - P&L'[Profit Date] <= TODAY()
)
// If the month has not expired, the estimated data is used
VAR Estimated_Resources =
CALCULATE(
SUMX('Fact_Projects Billing - P&L', 'Fact_Projects Billing - P&L'[ARC]),
'Fact_Projects Billing - P&L'[Profit Date] > TODAY()
)
VAR Estimated_Resources_ALL =
CALCULATE(
SUMX('Fact_Projects Billing - P&L', 'Fact_Projects Billing - P&L'[ARC]),
'Fact_Projects Billing - P&L'[Profit Date] > TODAY(),
ALLSELECTED()
)
VAR NumberOfMonths =
CALCULATE(
COUNTROWS(DISTINCT(Dim_Calendar[CalendarMonthYear]))
)
VAR MonthlyResourceCost = SUMX('Dim_Salary Proposal', 'Dim_Salary Proposal'[Total Company Cost (Fix+Var)] / 12 )
VAR NonBillingResourceCost =
IF(
DATE(SELECTEDVALUE(Dim_Calendar[CalendarYear]), SELECTEDVALUE(Dim_Calendar[CalendarMonth]),1) >= DATE(YEAR(TODAY()), MONTH(TODAY()),1),
CALCULATE(
SUMX('Dim_Salary Proposal', 'Dim_Salary Proposal'[Total Company Cost (Fix+Var)] / 12 ),
FILTER('Dim_Human Resources','Dim_Human Resources'[Email] IN {"ivancastro@maca-technology.com", "javiermacias@maca-technology.com", "macarenagonzalez@maca-technology.com"})
),
BLANK()
)
VAR TotalResourceCost = MonthlyResourceCost * NumberOfMonths
VAR PendingResources =
IF(
DATE(SELECTEDVALUE(Dim_Calendar[CalendarYear]), SELECTEDVALUE(Dim_Calendar[CalendarMonth]),1) >= DATE(YEAR(TODAY()), MONTH(TODAY()),1),
TotalResourceCost - Estimated_Resources_ALL,
BLANK()
)
VAR Total_Estimated_Resources =
IF(
ISINSCOPE('Dim_Project Database'[Program Name]) ,
SWITCH(
SELECTEDVALUE('Dim_Project Database'[Program Name]),
"Non billable" , NonBillingResourceCost,
"Internal Project", PendingResources - NonBillingResourceCost,
BLANK()
)
+
IF(HASONEVALUE('Dim_Project Database'[Program Name]), Estimated_Resources,BLANK())
,BLANK()
)
RETURN
Real_Resources +
Total_Estimated_Resources
One of the issues it that when I select more than one month, the "Total_Estimated_Resources " variable show blank and this is because the selected value that I use to check that the date is in the future, doesn't work as I need.
In overall the example summarized is:
@MacarenaGB , Try like
measure =
Var _disReal = calculate(DistinctCount(Table[Month Year]), allselected(Table), filter(Table, Not(isblank(Table[Real]))))
Var _dis = calculate(DistinctCount(Table[Month Year]), allselected(Table))
return
if(_disReal < _dis , sum(Table[Estimated]), Sum(Table[Real]))
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.