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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
amty63
Helper III
Helper III

can we use IF condition while using TOTALYTD function in calculated measure in POWER BI Desktop...

Hello, I am trying various formulas but didn't work any of them..

 

I think IF CONDITION IS NOT WORKING in a measure...

 

Comparison -YTD = CALCULATE(TOTALYTD(SUM(FACT_V1[V1_AMOUNT_EUR])/1000,'01_PERIOD'[PERIOD]),FILTER(FACT_V1_BU, FACT_V1_BU[MONTH]=FACT_V1_BU[MONTH_V1]))

 

Comparison -YTD1= SUMX(FACT_V1_BU, IF(FACT_V1_BU[MONTH]=FACT_V1_BU[MONTH_V1],TOTALYTD(SUM(FACT_V1_BU[V1_AMOUNT_EUR])/1000,'01_PERIOD'[PERIOD])))

 

 

Above Results are showing MTD Values only...

 

Am I missing something.. 

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

Hi @amty63 ,

 

IF CONDITION can work in a measure, such as:

Measure 4 = 
IF(
    MAX('Table 2'[Date]) <= DATE(2020, 12, 1),
    TOTALYTD(
        SUM('Table 2'[Column]),
        'Table 2'[Date]
    )
)

b12.PNG

For your Problem, maybe you can try this:

Comparison -YTD1 = 
 SUMX(
     FILTER(
         FACT_V1_BU,
         FACT_V1_BU[MONTH]=FACT_V1_BU[MONTH_V1]
     ),
     TOTALYTD(SUM(FACT_V1_BU[V1_AMOUNT_EUR])/1000,'01_PERIOD'[PERIOD])
 )

If the formula can't help you, please give me a sample data.

 

Best regards,
Lionel Chen

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-lionel-msft
Community Support
Community Support

Hi @amty63 ,

 

IF CONDITION can work in a measure, such as:

Measure 4 = 
IF(
    MAX('Table 2'[Date]) <= DATE(2020, 12, 1),
    TOTALYTD(
        SUM('Table 2'[Column]),
        'Table 2'[Date]
    )
)

b12.PNG

For your Problem, maybe you can try this:

Comparison -YTD1 = 
 SUMX(
     FILTER(
         FACT_V1_BU,
         FACT_V1_BU[MONTH]=FACT_V1_BU[MONTH_V1]
     ),
     TOTALYTD(SUM(FACT_V1_BU[V1_AMOUNT_EUR])/1000,'01_PERIOD'[PERIOD])
 )

If the formula can't help you, please give me a sample data.

 

Best regards,
Lionel Chen

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

 

parry2k
Super User
Super User

@amty63 what you are trying to achieve, share sample data, business problem and expected output.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors