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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Fuhrer786
Frequent Visitor

Change Column value based on category value

Hi Users,

 

I have 3 products and 5 forecasted models showing 5 diff forecasted values for each product. However in the table chart I only put my top 3 models which I have already decided based on prior data.The sample data looks like below:

 

Product  Year  Month  Fcstvalue1  FcstValue2  FcstValue3 

A             2019   7        100               200                 125

B              2019  7         2000             5000              3500

c              2019  7          150            200                300

 

What I know is for product C ,none of my top 3 models are accurate as compared to 4th model. So, I would like to put condition that when product=C then fcstvalue1=fsctvalue4 else fsctvalue1 but I am not able to quite get that DAX query right.

 

Note: The product field is coming from different table and all foreacasted values are in different  columns in another forecast table like Fsctvalue1,Fsctvalue2,Fsctvalue3,Fsctvalue4 and Fsctvalue5.

 

Thanks in Advance!

1 ACCEPTED SOLUTION

@Cmcmahan It worked by altering a bit. Thanks a ton!

 

Model1BestValue = IF(SELECTEDVALUE(Product[ProductID])="C",CALCULATE(sum(Forecast[Fsctvalue4])),CALCULATE(sum(Forecast[Fsctvalue1])))

View solution in original post

4 REPLIES 4
Cmcmahan
Resident Rockstar
Resident Rockstar

Sure, this is possible.  What sort of visual are you putting this in? A table? Matrix? Graph of some sort?

 

If you're using a matrix, you can use this measure:

Fcstvalue1SmartReplace = IF( SELECTEDVALUE(Product[ProductID]) = "C", SELECTEDVALUE(Forecast[fsctvalue4]), SELECTEDVALUE(Forecast[fsctvalue1]))

And replace the FcstValue1 in the values bucket of the visual with this measure.  Note that I'm assuming for any given year/month/product combination, there's only one value for fsctvalue4.  

@Cmcmahan It worked by altering a bit. Thanks a ton!

 

Model1BestValue = IF(SELECTEDVALUE(Product[ProductID])="C",CALCULATE(sum(Forecast[Fsctvalue4])),CALCULATE(sum(Forecast[Fsctvalue1])))

Glad you got it working!

 

Does it make sense to sum multiple forecast values?  For example, if I calculate this in a context where I have all products selected, would I want to SUM all the forecasts together? 

 

If not, I would replace your SUM aggregations with SELECTEDVALUE expressions, or another aggregation that makes sense.

Thanks for this solution, but the forecast4 value changes every year-month for product and I am using line and clustered chart

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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