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 @jiangxm80 , Just checking in as we haven’t received an update from you regarding last response. Were you able to resolve the issue with @jennratten & @Poojara_D12 's answer? If you have any other issue please raise new post.
If solution was helpful, please mark it as Accept Answer and click Yes to confirm.
Feel free to let us know if you have any further questions—we’re here to help!
Thank you for being a part of the Microsoft Fabric Community Forum!
Hi @jiangxm80
Your DAX script uses TREATAS to dynamically apply filters on the SalesForecastDetails table. To apply these filters conditionally based on other conditions, you can introduce logic in your DAX query by combining the IF, SWITCH, or conditional logic functions.
Below is an example of how you can adapt your script to include conditional logic for applying the filters:
VAR __DS0FilterTable =
IF(
NOT(ISBLANK(@{variables('strVersionNo')})),
TREATAS({@{variables('strVersionNo')}}, 'SalesForecastDetails'[VersionNo]),
BLANK()
)
VAR __DS1FilterTable =
IF(
NOT(ISBLANK(@{variables('strProductGroup')})),
TREATAS({@{variables('strProductGroup')}}, 'SalesForecastDetails'[ProductGroup]),
BLANK()
)
VAR __DS2FilterTable =
IF(
NOT(ISBLANK(@{variables('strCategory')})),
TREATAS({@{variables('strCategory')}}, 'SalesForecastDetails'[Category]),
BLANK()
)
VAR __DS0Core =
CALCULATETABLE(
SUMMARIZE(
'SalesForecastDetails',
'SalesForecastDetails'[YearNo],
'SalesForecastDetails'[MonthNo],
'SalesForecastDetails'[VersionNo],
'SalesForecastDetails'[Region],
'SalesForecastDetails'[Area],
'SalesForecastDetails'[ProductGroup],
'SalesForecastDetails'[Category],
'SalesForecastDetails'[SubCategory],
'SalesForecastDetails'[ProductNo],
'SalesForecastDetails'[ProductSpec],
'SalesForecastDetails'[FinalQty_Accum],
'SalesForecastDetails'[FinalAmt_Accum],
'SalesForecastDetails'[Left],
'SalesForecastDetails'[LeftAmt],
'SalesForecastDetails'[Sample],
'SalesForecastDetails'[SampleAmt],
'SalesForecastDetails'[Inv],
'SalesForecastDetails'[InvAmt],
'SalesForecastDetails'[FinalQty],
'SalesForecastDetails'[FinalAmt],
'SalesForecastDetails'[LInv],
'SalesForecastDetails'[LInvAmt]
),
KEEPFILTERS(__DS0FilterTable),
KEEPFILTERS(__DS1FilterTable),
KEEPFILTERS(__DS2FilterTable),
'SalesForecastDetails'[FinalQty_Accum] <> 0
|| 'SalesForecastDetails'[FinalAmt_Accum] <> 0
|| 'SalesForecastDetails'[Left] <> 0
|| 'SalesForecastDetails'[LeftAmt] <> 0
|| 'SalesForecastDetails'[Sample] <> 0
|| 'SalesForecastDetails'[SampleAmt] <> 0
|| 'SalesForecastDetails'[Inv] <> 0
|| 'SalesForecastDetails'[InvAmt] <> 0
|| 'SalesForecastDetails'[FinalQty] <> 0
|| 'SalesForecastDetails'[FinalAmt] <> 0
|| 'SalesForecastDetails'[LInv] <> 0
|| 'SalesForecastDetails'[LInvAmt] <> 0
)
EVALUATE
__DS0Core
You can extend the logic further by introducing additional conditions (e.g., based on other column values or external variables) in the IF statements.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Thanks for the help.
it seems some error as the folloiwng.
{"type":1,"value":"Query (8, 13) Too few arguments were passed to the ISBLANK function. The minimum argument count for the function is 1."}},
Hi @jiangxm80 -
The error thrown is stating that the ISBLANK function is being called without a required argument. The argument could be a value or an expression to check for blank. In your script, it looks like one of the variables @{variables('strVersionNo')}, @{variables('strProductGroup')}, or @{variables('strCategory')} might not be successfully resolved, which could be why the ISBLANK function is executing without an argument.
Here are some suggestions:
VAR __DS0FilterTable =
IF(
NOT(ISBLANK("Version1")),
TREATAS({"Version1"}, 'SalesForecastDetails'[VersionNo]),
BLANK()
)
VAR __DS1FilterTable =
IF(
NOT(ISBLANK("ProductGroup1")),
TREATAS({"ProductGroup1"}, 'SalesForecastDetails'[ProductGroup]),
BLANK()
)
VAR __DS2FilterTable =
IF(
NOT(ISBLANK("Category1")),
TREATAS({"Category1"}, 'SalesForecastDetails'[Category]),
BLANK()
)
VAR __DS0Core =
CALCULATETABLE(
SUMMARIZE(
'SalesForecastDetails',
'SalesForecastDetails'[YearNo],
'SalesForecastDetails'[MonthNo],
'SalesForecastDetails'[VersionNo],
'SalesForecastDetails'[Region],
'SalesForecastDetails'[Area],
'SalesForecastDetails'[ProductGroup],
'SalesForecastDetails'[Category],
'SalesForecastDetails'[SubCategory],
'SalesForecastDetails'[ProductNo],
'SalesForecastDetails'[ProductSpec],
'SalesForecastDetails'[FinalQty_Accum],
'SalesForecastDetails'[FinalAmt_Accum],
'SalesForecastDetails'[Left],
'SalesForecastDetails'[LeftAmt],
'SalesForecastDetails'[Sample],
'SalesForecastDetails'[SampleAmt],
'SalesForecastDetails'[Inv],
'SalesForecastDetails'[InvAmt],
'SalesForecastDetails'[FinalQty],
'SalesForecastDetails'[FinalAmt],
'SalesForecastDetails'[LInv],
'SalesForecastDetails'[LInvAmt]
),
KEEPFILTERS(__DS0FilterTable),
KEEPFILTERS(__DS1FilterTable),
KEEPFILTERS(__DS2FilterTable),
'SalesForecastDetails'[FinalQty_Accum] <> 0
|| 'SalesForecastDetails'[FinalAmt_Accum] <> 0
|| 'SalesForecastDetails'[Left] <> 0
|| 'SalesForecastDetails'[LeftAmt] <> 0
|| 'SalesForecastDetails'[Sample] <> 0
|| 'SalesForecastDetails'[SampleAmt] <> 0
|| 'SalesForecastDetails'[Inv] <> 0
|| 'SalesForecastDetails'[InvAmt] <> 0
|| 'SalesForecastDetails'[FinalQty] <> 0
|| 'SalesForecastDetails'[FinalAmt] <> 0
|| 'SalesForecastDetails'[LInv] <> 0
|| 'SalesForecastDetails'[LInvAmt] <> 0
)
EVALUATE
__DS0Core
If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.
Proud to be a Microsoft Fabric Super User
thanks, I have tried, should be fine now.
but there is a new issue, when the __DS2FilterTable is BLANK(), it will show some error as the following.
The True/False expression does not specify a column. Each True/False expressions used as a table filter expression must refer to exactly one column
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.