Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
DAX USED: SWITCH(SELECTEDVALUE('View By'[Parameter Order]),
0,RANKX(FILTER(ALLSELECTED(Product[company_name]),NOT(ISBLANK([Sales by Current Month]))),[Sales by Current Month)),
1,RANKX(FILTER(ALLSELECTED(Product[BRAND_NAME]),NOT(ISBLANK([Sales by Current Month]))),[Sales by Current Month))
In the above mentioned scenerio we are trying to refer different columns(more than five) from same table.
In that case, the query checks 5 times for the correct value and then gives the output.
so I tried creating a variable and pass it to the 5 columns as field parameter column and use SELECTEDVALUE to retrieve the selected value from the filter.
Unfortunately variables are not accepted in certain DAX Functions like SUM and ALLSELECTED.
Is there a workaround or a solution for the DAX to be more efficient and improve the performance.
Hi @kompalli
After I testing, the sum(), allselected() can support variables
e.g
Measure = SUMX(FILTER(ALLSELECTED('Table (2)'),[CUS]=MAX([CUS])),[value])
Measure 2 = SWITCH(SELECTEDVALUE(Parameter[Parameter Order]),0,RANKX(FILTER(ALLSELECTED('Table (2)'[CUS]),[Measure]>30),[Measure],,ASC,Dense),1,0)
Output:
Can you provide some detail error message or pbix file, I can offer more help.
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 97 | |
| 73 | |
| 50 | |
| 46 | |
| 44 |