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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JIN23
Helper I
Helper I

IF/SWICH error, I can not bring column to the condition

Hi. 

 

I have transformed the data from power query to BI and now trying to make the new measure like

If season type  = " Budgeting" & Market = "UO", Sales gross ACC / 66% ..............

 

But the thing is, power bi can not find the volume of season type and Market even it is in the table clearly. they can only bring other measures that I have created..

 

Is there anyway I can bring season type and Market to the if condition?

 

here is the table.

 

JIN23_0-1723192955552.pngJIN23_1-1723192980370.png

Dax that I am trying to write is

SWITCH(
TRUE(),
-- UX-O7 conditions
FT_Main[Season type] = "Budgeting" && FT_Main[Planning Market] = "UX-O7", FT_Main[Sales gross plan acc] / 0.66,
FT_Main[Season type] = "Planning" && FT_Main[Planning Market] = "UX-O7", FT_Main[Sales gross plan acc] / 0.65,

 

If I try to put season type in power bi, 

JIN23_2-1723193074211.png

THEY DO NOT FIND ANY MY FT TABLE AND ANY COLUMNS...

 

Please kindly support. 

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

Hi @JIN23 ,

 

Thanks for the reply from rajendraongole1 , please allow me to provide another insight: 

 

You should understand the difference between a calculated column and a measure in DAX.


A "calculated column" is a column created in a table, just like any other column. However, the result of a calculated column counts against a calculated expression (DAX). Typically, a calculated column utilises a DAX expression applied to each row in the dataset and the result is stored in a new column. One of the very important concepts about computation that is applied in a computed column (which in most cases is not always the case); is computation one row at a time, or in other words; row by row.

 

Measures are usually calculations that work at the aggregation level. Measures are dynamic in nature; they affect a subset of the data in one or more tables. Therefore, the subset of data can be changed through filters applied in Power BI reports, and the calculations must then be evaluated dynamically. Therefore, measures are not pre-calculated, but are calculated on-the-fly as they are added to the report.


More information about the difference can be found at the link:

Measure vs Calculated Column: The Mysterious Question? Not! - RADACAD

Difference Between Calculated Column and Measure in Power BI - SharePoint & Microsoft Power Platform...

 

So, in my example data, if you use a calculated column, you can use the following formula:

Column =
SWITCH(TRUE(),
'financials'[Country] = "Canada" && 'financials'[Discount Band] = "Low",1)

vkaiyuemsft_0-1723426800786.png

 

If you use a measure , you can use the following formula:

Measure =
SWITCH(TRUE(),
MAX('financials'[Country]) = "Canada" && MAX('financials'[Discount Band]) = "Low", 1)

vkaiyuemsft_1-1723426887709.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

 

View solution in original post

4 REPLIES 4
v-kaiyue-msft
Community Support
Community Support

Hi @JIN23 ,

 

Thanks for the reply from rajendraongole1 , please allow me to provide another insight: 

 

You should understand the difference between a calculated column and a measure in DAX.


A "calculated column" is a column created in a table, just like any other column. However, the result of a calculated column counts against a calculated expression (DAX). Typically, a calculated column utilises a DAX expression applied to each row in the dataset and the result is stored in a new column. One of the very important concepts about computation that is applied in a computed column (which in most cases is not always the case); is computation one row at a time, or in other words; row by row.

 

Measures are usually calculations that work at the aggregation level. Measures are dynamic in nature; they affect a subset of the data in one or more tables. Therefore, the subset of data can be changed through filters applied in Power BI reports, and the calculations must then be evaluated dynamically. Therefore, measures are not pre-calculated, but are calculated on-the-fly as they are added to the report.


More information about the difference can be found at the link:

Measure vs Calculated Column: The Mysterious Question? Not! - RADACAD

Difference Between Calculated Column and Measure in Power BI - SharePoint & Microsoft Power Platform...

 

So, in my example data, if you use a calculated column, you can use the following formula:

Column =
SWITCH(TRUE(),
'financials'[Country] = "Canada" && 'financials'[Discount Band] = "Low",1)

vkaiyuemsft_0-1723426800786.png

 

If you use a measure , you can use the following formula:

Measure =
SWITCH(TRUE(),
MAX('financials'[Country]) = "Canada" && MAX('financials'[Discount Band]) = "Low", 1)

vkaiyuemsft_1-1723426887709.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

 

rajendraongole1
Super User
Super User

Hi @JIN23 - can you please create a calculcuted column with switch:

YourMeasureName =
SWITCH(
TRUE(),
FT_Main[Season type] = "Budgeting" && FT_Main[Planning Market] = "UO", FT_Main[Sales gross plan acc] / 0.66,
FT_Main[Season type] = "Planning" && FT_Main[Planning Market] = "UO", FT_Main[Sales gross plan acc] / 0.65,
BLANK()
)

 

stillissue exist, please share sample data will check 

 

Hope it works





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi. Could you elaborate a bit more on calculated column? I have clicked new measurement then wrote those formula but I could not bring season type and planning market to the condition. BI said, they can not find the columns of season type and planning market even I do have it as the above pic..

Hi @JIN23 - It is a measure calculation, not cc

 

still issue exist, Please share sample data and expectations. 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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