March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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) )
Solved! Go to Solution.
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,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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.
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,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Also, thank you again so much for taking the time and putting the efforts into this, @v-kongfanf-msft . That's awesome!
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.
if(checkbox is true, Calculate( something, all(dates)))
You get the "do nothing" for free if you omit the "else" parameter.
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
18 | |
15 | |
9 | |
8 |
User | Count |
---|---|
37 | |
32 | |
18 | |
16 | |
13 |