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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
vidheesha
New Member

Stuck with the sum and if

Hi All,

 

I am trying to replicate the SQL case when statement in the Power BI as a calculated measure.

The SQL statement is 

 

(CASE WHEN 'Target Flag' = 'Actual' AND 'Date.FYear' = '2023'

THEN 'X.var'

ELSE 0 

END)

 

The calculated measure has to SUM the X.var if the above 

conditions are true

 

 

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @vidheesha ;

Try it.

measure =
IF (
    MAX ( [Target Flag] ) = "Actual"
        && MAX ( [Date.FYear] ) = 2023,
    SUM ( [X.var] ),
    0
)


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @vidheesha ;

Try it.

measure =
IF (
    MAX ( [Target Flag] ) = "Actual"
        && MAX ( [Date.FYear] ) = 2023,
    SUM ( [X.var] ),
    0
)


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VijayP
Super User
Super User

@vidheesha 

Switch(sum(valuecolumn), 'Target Flag' = 'Actual' && 'Date.FYear' = '2023', "Required value",0)

 

More powerbi tips on www.youtube.com/perepavijay




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors