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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Solution Authors