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
I am using calculate function extensively for creating many measures . However for many measures the filter condition of the Calculate is common (example shown below) . Is there any way to create a filter variable or parameter or something to store this filter which I can refer/use in calculate functions of different measures as filter condition
Table[Fieldintable] = "abc" ||
Table[Fieldintable] = "def" ||
Table[Fieldintable] = "ghi" ||
Table[Fieldintable] = "ljk"
Solved! Go to Solution.
Hi @ashwinkolte ,
@amitchandak Thanks for your reply!
@ashwinkolte If I understand you correctly, you mean to somehow reference this entire DAX without having to rewrite this code all over again in another DAX?
I'm sorry this can't be done in DAX because this DAX is not complete, you can only store a complete DAX in Desktop (i.e. one that can output results properly) and not just a few lines of code.
If it is too much trouble for you to list all the conditions that need to be met by the Fieldintable each time, you can try the following:
Use this DAX to create a calculated table:
Slicer = VALUES('Table'[Fieldintable])
Use this table to create a slicer:
Then you can change your DAX like this (for example)
Measure =
CALCULATE(
SUM('Table'[Value]),
'Table'[Fieldintable] IN VALUES(Slicer[Fieldintable])
)
What you need to calculate in Fieldintable, you just need to select it in slicer, no need to list them one by one in DAX.
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HI @amitchandak Thanks for responding but that was not my question .I want to use that whole expression whther you use "=" or "IN" in other measures . So how can I have it in a parameter or a globally avaliable variable which I can just input as a filter value of Calculate function in other measures , rather than specifying all those values again in another measure . Hope the question is clear
Hi @ashwinkolte ,
@amitchandak Thanks for your reply!
@ashwinkolte If I understand you correctly, you mean to somehow reference this entire DAX without having to rewrite this code all over again in another DAX?
I'm sorry this can't be done in DAX because this DAX is not complete, you can only store a complete DAX in Desktop (i.e. one that can output results properly) and not just a few lines of code.
If it is too much trouble for you to list all the conditions that need to be met by the Fieldintable each time, you can try the following:
Use this DAX to create a calculated table:
Slicer = VALUES('Table'[Fieldintable])
Use this table to create a slicer:
Then you can change your DAX like this (for example)
Measure =
CALCULATE(
SUM('Table'[Value]),
'Table'[Fieldintable] IN VALUES(Slicer[Fieldintable])
)
What you need to calculate in Fieldintable, you just need to select it in slicer, no need to list them one by one in DAX.
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
WOW . Thankyo so much !!
User | Count |
---|---|
58 | |
56 | |
55 | |
50 | |
32 |
User | Count |
---|---|
172 | |
89 | |
70 | |
46 | |
45 |