Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Dax Query

HI Team,

 

I need support. I have two dax queries one is A other is B. I need another dax query C in which logic should be like i have one column named as remark. So query should be like C =if(remark == AA give me A, remark == BB, B). But i am unable to use If condition with a column in dax query. Is there any other way, i tried switch true as well but after using it i am giving selected value as well due to which i need to select AA or BB or both in the slicer. If i am selecting both then only numbers are showing correct. Can anyone help me in this, it's urgent. Thanks in advance.

 

My query - 

GM% = SWITCH(TRUE(),SELECTEDVALUE('T1'[Remark])="AA",[AT%],SELECTEDVALUE('T1'[Remark])="AB",[AB%])
2 REPLIES 2
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1716432790511.png

 

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
DISTINCT('Table'[Remake])

vyangliumsft_1-1716432790513.png

2. Create measure.

Test =
var _select=SELECTCOLUMNS('Table 2',"select",[Remake])
var _count=COUNTX(ALLSELECTED('Table 2'),[Remake])
return
SWITCH(
    TRUE(),
    "AA" in _select && _count =1,[MeasureA],
    "BB" in _select && _count =1,[MeasureB],
    "AA" in _select && "BB" in _select && _count=2,1
)

3. Result:

Select“AA”:

vyangliumsft_2-1716432813255.png

Select”BB”:

vyangliumsft_3-1716432843297.png

Select“AA”&&”BB”:

vyangliumsft_4-1716432843298.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

Hi Bro, Thanks for your time. I tried your approach but it's giving me the same number for all the countries even after establishing the relationship as well between the tables. I did some changes in the query and cross checking the numbers let's see if that would be correct then i'll post it here as well. But thanks for your effort and time. Really appreciating. 

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors