Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MacarenaGB
Helper II
Helper II

Selectedvalue of multiple Date to use different measures comparing to Today

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 =

IF(
DATE(SELECTEDVALUE(Dim_Calendar[CalendarYear]), SELECTEDVALUE(Dim_Calendar[CalendarMonth]),1) < DATE(YEAR(TODAY()), MONTH(TODAY()),1),
[Measure for the future)
)
Screenshot_19.png

1 ACCEPTED SOLUTION
MacarenaGB
Helper II
Helper II

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 


View solution in original post

5 REPLIES 5
MacarenaGB
Helper II
Helper II

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 


amitchandak
Super User
Super User

@MacarenaGB ,The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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:
Screenshot_20.png

Screenshot_21.png

@amitchandak any solution?

Thanks!

@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]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors