cancel
Showing results 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

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
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]
)
)``````

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])
)``````

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.

2 REPLIES 2
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]
)
)``````

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])
)``````

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.

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.