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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
THENNA_41
Post Partisan
Post Partisan

Condition is not working

Data Sampple:

Local FPV'[prod Cat] Local FPV'[Markets]  Local FPV'[Cigarettes Per Pack (Product Information)] Local FPV'[Cigarettes Per Outer (*)]
0                           CA04                                                       180                                                                  180
0                          CA04                                                        18                                                                    180
0                          CA04                                                       180                                                                   180
0                           TW04                                                      122                                                                   50
1                          DE04                                                       50                                                                      88


already measures are created based on the condition

Local FPV'[prod Cat]= 0 then [#Gross_FPV]

Local FPV'[prod Cat]= 1 then [#Gross_otp]


Current Dax

#G =
Var selval=SELECTEDVALUE('Local FPV'[prod Cat],"Nothing Selected")
RETURN
ROUND(IF(selval=0,[#Gross_FPV],IF(selval=1,[#Gross_otp],BLANK())),3)

 

Now i want add new calculation if below condtion match then [#Gross_180_cal]


Local FPV'[prod Cat] Local FPV'[Markets] Local FPV'[Cigarettes Per Pack (Product Information)] Local FPV'[Cigarettes Per Outer (*)]
0                                            CA04                                              180                                                           180

IF( Local FPV'[prod Cat] =0 && Local FPV'[Cigarettes Per Pack (Product Information)]=180 && Local FPV'[Cigarettes Per Outer (*)=180]


#Gross_FPV_180

IF( Local FPV'[prod Cat] =0 && Local FPV'[Cigarettes Per Pack (Product Information)]<>180 && Local FPV'[Cigarettes Per Outer (*)<>180]

[#Gross_FPV]

IF Local FPV'[prod Cat]= 1 then [#Gross_otp]


created DAX but  [#Gross_FPV_180],  this condition code not working 

 

Var selval = SELECTEDVALUE('Local FPV'[prod Cat], "Nothing Selected")
Var market = SELECTEDVALUE('Local FPV'[Markets], "Unknown Market")
Var cigpack=SELECTEDVALUE('Local FPV'[Cigarettes Per Pack (Product Information)],"Nothing selectd")
var cigouter=SELECTEDVALUE('Local FPV'[Cigarettes Per Outer (*)],"Nothing selected")
RETURN
ROUND(
SWITCH(
TRUE(),
selval = 0 && cigpack =180 && cigouter=180, [#Gross_FPV_180],
selval = 0 && cigpack <> 180 && cigouter= <>180, [#Gross_FPV],
selval = 1, [#Gross_otp],
BLANK()
),
3
)

selval = 0 && cigpack =180 && cigouter=180, [#Gross_FPV_180] this condition not working .please any one help me ..

1 ACCEPTED SOLUTION
v-jianpeng-msft
Community Support
Community Support

Hi, @THENNA_41 

Based on the data you provided and the DAX expression, I tested that it works. Here are some of the how-to procedures:

I created three measures using the following DAX expression:

#Gross_FPV = 0
#Gross_FPV_180 = 1
#Gross_otp = -1

vjianpengmsft_0-1714359317714.png

I created a condition using the DAX expression you provided:

vjianpengmsft_1-1714359377624.png

I created a table visual and tested this condition:

vjianpengmsft_2-1714359603452.png

If you see #Gross_FPV_180=1 in measure, you have no problem with your DAX expression. I've uploaded the test file below for you to preview.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

 

 

View solution in original post

1 REPLY 1
v-jianpeng-msft
Community Support
Community Support

Hi, @THENNA_41 

Based on the data you provided and the DAX expression, I tested that it works. Here are some of the how-to procedures:

I created three measures using the following DAX expression:

#Gross_FPV = 0
#Gross_FPV_180 = 1
#Gross_otp = -1

vjianpengmsft_0-1714359317714.png

I created a condition using the DAX expression you provided:

vjianpengmsft_1-1714359377624.png

I created a table visual and tested this condition:

vjianpengmsft_2-1714359603452.png

If you see #Gross_FPV_180=1 in measure, you have no problem with your DAX expression. I've uploaded the test file below for you to preview.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors