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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
cathyPB
Frequent Visitor

IF statement with Calculated Measure

 I would like to create a new measure with some value like this:

IF  Before today:

CALCULATE(
 SUM('DataMart'[ACTUAL]),
 FILTER(
  ALLSELECTED('DIM_DATE'[DAY_DATE]),
  ISONORAFTER('DIM_DATE'[DAY_DATE], max(DIM_DATE[DAY_DATE]), DESC)))

If it After today: 0

 

Any suggestions?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@cathyPB - Does this measure work?:

 

Your Measure 2 = 
var _Date_As_Of = MAX('Dim_Date'[Day_Date])
return CALCULATE(
    SUM('DataMart'[ACTUAL]),
    FILTER(
        ALL('Dim_Date'),
        AND(_Date_As_Of < TODAY(), 'Dim_Date'[Day_Date] <= _Date_As_Of)
    )
)

 

 

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

@cathyPB - Could you please clarify: are you wanting to compare the fact table date vs today's date and return 0 if it's in the future?

Yes, I do have Date dimension as well.

Anonymous
Not applicable

@cathyPB  - Check whether this Measure works:

Your Measure = 
CALCULATE(
    SUM('DataMart'[ACTUAL]),
    FILTER(
        'Dim_Date',
        'Dim_Date'[Day_Date] < TODAY()
    )
)
I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.

 

Thanks for reply, but I would like to get accumulative sum result as following:

CALCULATE(
 SUM('DataMart'[ACTUAL]),
 FILTER(
  ALLSELECTED('DIM_DATE'[DAY_DATE]),
  ISONORAFTER('DIM_DATE'[DAY_DATE], max(DIM_DATE[DAY_DATE]), DESC)))

Anonymous
Not applicable

@cathyPB - Does this measure work?:

 

Your Measure 2 = 
var _Date_As_Of = MAX('Dim_Date'[Day_Date])
return CALCULATE(
    SUM('DataMart'[ACTUAL]),
    FILTER(
        ALL('Dim_Date'),
        AND(_Date_As_Of < TODAY(), 'Dim_Date'[Day_Date] <= _Date_As_Of)
    )
)

 

 

Anonymous
Not applicable

Hello,

 

I am also having a similar issue. I am looking to do something like this. IF week = 1 and timesheet issue = missing  then missing if week = 1 and timesheet = good then sum actual hours. I want the results to populate in the same column. Any suggestions?

Anonymous
Not applicable

@Anonymous - Please post a new thread, and refer to this blog post for guidance.

Not yet, it only return one value as the point in the chart

Anonymous
Not applicable

@cathyPB  - Could you please mock up what you are looking for and provide a screenshot of what is currently happening?

@Anonymous   It works. The dot comes from the higher level, so drill down to lower level does work.Thanks. 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.