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

Resolver II

## conditional all()??

Hi. I have a calculate function. I need to decide on the fly whether it uses all() (based on user input in a checkbox) as one of its arguments. Is this at all possible? Calculate( something, if(checkbox is true, all(dates), do nothing) )

2 ACCEPTED SOLUTIONS
Community Support

Hi @yasbos ,

Maybe you can try formula like below:

``````ConditionalTotalSales =
IF(
[SelectedOption] = "Include All",
CALCULATE(
[TotalSales],
ALL('Calendar')
),
CALCULATE(
[TotalSales]
)
)``````
``````SelectedOption = SELECTEDVALUE(Checkbox[Option], "Exclude All")
``````
``TotalSales = SUM(Sales[Sales])``

Best Regards,

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

Resolver II

Thanks so much, @lbendlin . I forgot to mention that I did know this solution, but I was hoping for a more localized decision because the calculate function that I have is much larger than just one line. I was hoping to modularize the code. Thanks so much for your help, nonetheless.

5 REPLIES 5
Community Support

Hi @yasbos ,

Maybe you can try formula like below:

``````ConditionalTotalSales =
IF(
[SelectedOption] = "Include All",
CALCULATE(
[TotalSales],
ALL('Calendar')
),
CALCULATE(
[TotalSales]
)
)``````
``````SelectedOption = SELECTEDVALUE(Checkbox[Option], "Exclude All")
``````
``TotalSales = SUM(Sales[Sales])``

Best Regards,

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

Resolver II

Also, thank you again so much for taking the time and putting the efforts into this, @v-kongfanf-msft . That's awesome!

Resolver II

Thanks so much @v-kongfanf-msft . I forgot to mention that I did know this solution, but I was hoping for a more localized decision because the calculate function that I have is much larger than just one line. I was hoping to modularize the code. Thanks so much for your help, nonetheless.

Super User

if(checkbox is true, Calculate( something, all(dates)))

You get the "do nothing"  for free if you omit the "else" parameter.

Resolver II

Thanks so much, @lbendlin . I forgot to mention that I did know this solution, but I was hoping for a more localized decision because the calculate function that I have is much larger than just one line. I was hoping to modularize the code. Thanks so much for your help, nonetheless.

Announcements

#### 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.

#### Power BI Monthly Update - August 2024

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

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors