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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
cruzp
Helper V
Helper V

IF ELSE Time Calculated Measure

Hello, i have a calculated measure below in this table.

 

Is there a way to update the measure below that uses DAX like VAR that cuts by half the actuals on the current month we are in to future months and retain the base actuals on prior months to current for specific employee EMP01?

 

cruzp_0-1726724123631.png

 

 

Measure = 
IF (     ISINSCOPE(DCC[CC_NAME])&&NOT(ISINSCOPE(DE[NameID])),
        SUMX(DE, [Hours]),
        IF (
            ISINSCOPE(DE[NameID]),
            [Hours],
            SUMX(DE, [Hours])
        )
    )

 

 
For this example, numbers from September 2024 to future months will be divided by 2. 
 
Any months prior to Sep 2024 will be retained.
5 REPLIES 5
Anonymous
Not applicable

Hi @cruzp ,

I also create a table and show the matrix as you mentioned.

vyilongmsft_0-1726800476710.png

vyilongmsft_1-1726800499406.png

Next I create a measure and here is the DAX code.

Measure = 
VAR _CurrentMonth =
    MONTH ( TODAY () )
VAR _CurrentYear =
    YEAR ( TODAY () )
VAR _CurrentDate =
    TODAY ()
VAR _EmployeeID =
    SELECTEDVALUE ( 'Table'[Name] )
RETURN
    SUMX (
        FILTER ( 'Table', 'Table'[Name] = _EmployeeID ),
        IF (
            'Table'[Date] >= DATE ( _CurrentYear, _CurrentMonth, 1 ),
            'Table'[Total] / 2,
            'Table'[Total]
        )
    )

vyilongmsft_2-1726800775379.png

vyilongmsft_3-1726800895648.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

bhanu_gautam
Super User
Super User

@cruzp , Try using below measure

 

Measure =
VAR CurrentMonth = MONTH(TODAY())
VAR CurrentYear = YEAR(TODAY())
VAR TargetEmployee = "EMP01"
RETURN
IF (
ISINSCOPE(DCC[CC_NAME]) && NOT(ISINSCOPE(DE[NameID])),
SUMX(
DE,
IF (
DE[NameID] = TargetEmployee &&
(YEAR(DE[Date]) > CurrentYear OR (YEAR(DE[Date]) = CurrentYear && MONTH(DE[Date]) >= CurrentMonth)),
[Hours] / 2,
[Hours]
)
),
IF (
ISINSCOPE(DE[NameID]),
IF (
DE[NameID] = TargetEmployee &&
(YEAR(DE[Date]) > CurrentYear OR (YEAR(DE[Date]) = CurrentYear && MONTH(DE[Date]) >= CurrentMonth)),
[Hours] / 2,
[Hours]
),
SUMX(
DE,
IF (
DE[NameID] = TargetEmployee &&
(YEAR(DE[Date]) > CurrentYear OR (YEAR(DE[Date]) = CurrentYear && MONTH(DE[Date]) >= CurrentMonth)),
[Hours] / 2,
[Hours]
)
)
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






hi @bhanu_gautam the date is in different table named DD, but i could not referenced it? how do i able to call it?

To reference a date from a different table in DAX, you need to ensure that there is a relationship between the tables. Assuming you have a relationship between the DE table and the DD table, you can use the RELATED function to access the date from the DD table. Here is the updated measure:

 

Measure =
VAR CurrentMonth = MONTH(TODAY())
VAR CurrentYear = YEAR(TODAY())
VAR TargetEmployee = "EMP01"
VAR IsCurrentOrFutureMonth =
YEAR(RELATED(DD[Date])) > CurrentYear ||
(YEAR(RELATED(DD[Date])) = CurrentYear && MONTH(RELATED(DD[Date])) >= CurrentMonth)

RETURN
IF (
ISINSCOPE(DCC[CC_NAME]) && NOT(ISINSCOPE(DE[NameID])),
SUMX(
DE,
IF (
DE[NameID] = TargetEmployee && IsCurrentOrFutureMonth,
[Hours] / 2,
[Hours]
)
),
IF (
ISINSCOPE(DE[NameID]),
IF (
DE[NameID] = TargetEmployee && IsCurrentOrFutureMonth,
[Hours] / 2,
[Hours]
),
SUMX(
DE,
IF (
DE[NameID] = TargetEmployee && IsCurrentOrFutureMonth,
[Hours] / 2,
[Hours]
)
)
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






hi @bhanu_gautam they dont have relationship. how can i make it work if that's the case?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.