The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi Eveeryone,
I am facing measure issue whilest creating switch condiiotn in measure.I am using this measure in field parameter but it is taking longer time to load and at the end it is failing .
1
Product | Sales | actuals | Flag |
1 | 10 | 60 | 1 |
2 | 20 | 70 | 0 |
3 | 30 | 80 | blank() |
4 | 40 | 90 | 1 |
5 | 50 | 100 | 0 |
Written measure=
1. Sales=Sum(sales)
2. Actuals=sum(Actuals)
3. Swith_level_flag=
Var Selected_=selectedvalue(product[flag])
return
)
I know it is simple measure but when I mausing with parameter it is failing .Is there any workaround?, I write in other way so it will be more faster@v-yueyunzh-msft
@amitchandak
Guys can you please help me on this.Is there any workaround I can write in another way.
Solved! Go to Solution.
Hi, @sanc_152
You can try the following methods.
Written measure =
Var _Sales=SUM('Table'[Sales])
Var _Actuals=SUM('Table'[Actuals])
Var _Selected_=SELECTEDVALUE('Table'[Flag])
return
SWITCH(TRUE(),
_Selected_=1,_Actuals,
OR(_Selected_=0,_Selected_=BLANK()),_Sales,
_Sales
)
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
There are a few things that could be causing performance issues with your measure. One thing to consider is the use of the selectedvalue() function, which can be expensive and slow down your measure. Instead, you could try using a disconnected table to store the flag values and use a slicer to select the desired flag value.
Additionally, you could try simplifying your measure by combining the Sales and Actuals measures into one measure using an IF statement, rather than using the SWITCH function. Here's an example of how you could write the measure:
Sales and Actuals Measure = VAR SelectedFlag = SELECTEDVALUE(Product[Flag]) RETURN IF( SelectedFlag = 1, SUM(Actuals), SUM(Sales) )
This measure uses a single IF statement to check the selected flag value and return the appropriate sum value based on the flag. This should be simpler and more efficient than using the SWITCH function.
There are a few things that could be causing performance issues with your measure. One thing to consider is the use of the selectedvalue() function, which can be expensive and slow down your measure. Instead, you could try using a disconnected table to store the flag values and use a slicer to select the desired flag value.
Additionally, you could try simplifying your measure by combining the Sales and Actuals measures into one measure using an IF statement, rather than using the SWITCH function. Here's an example of how you could write the measure:
Sales and Actuals Measure = VAR SelectedFlag = SELECTEDVALUE(Product[Flag]) RETURN IF( SelectedFlag = 1, SUM(Actuals), SUM(Sales) )
This measure uses a single IF statement to check the selected flag value and return the appropriate sum value based on the flag. This should be simpler and more efficient than using the SWITCH function.
Hi, @sanc_152
You can try the following methods.
Written measure =
Var _Sales=SUM('Table'[Sales])
Var _Actuals=SUM('Table'[Actuals])
Var _Selected_=SELECTEDVALUE('Table'[Flag])
return
SWITCH(TRUE(),
_Selected_=1,_Actuals,
OR(_Selected_=0,_Selected_=BLANK()),_Sales,
_Sales
)
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
65 | |
61 | |
60 | |
54 | |
30 |
User | Count |
---|---|
180 | |
88 | |
72 | |
48 | |
46 |