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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rtaylor
Helper III
Helper III

DAX snytax to replace measure values with another value

Hello,

 

I have a measure that calculates sum of sales. I want to be able to replace data from this measure, and use it to aid in projections. Currently the formula I have adds $3000 to every available line regardless of filters. Please see below the example of what I would like to happen.

 

Example Table Visual NOT Dax Table

Starting Table               
 Jan Feb Mar Apr May Jun Total  
Sales $           873,629.95  $  1,023,080.00  $  149,450.05  $  2,046,160.00  $   872,075.42  $  1,236,366.00  $  6,200,761.42  
                
Replace with               
   Feb            
Sales  3000            
                
End Result               
 Jan Feb Mar Apr May Jun    
Sales $           873,629.95 3000  $  149,450.05  $  2,046,160.00  $   872,075.42  $  1,236,366.00  $  5,180,681.42  
                
                
What if Parameter = $3000               
Current formula not working               
Calculate(sum(salestable[sales]))-(Calculate(sum(sales),Date[Month])+What if Parameter)               
1 ACCEPTED SOLUTION

@rtaylor that is what I was looking for, selected month

 

My Measure = 
IF ( SELECTEDVALUE ( Table[Month selected by user] ) = SELECTEDVALUE ( Datatable[Month] ), [What if parameter value], SUM ( Table[Amount] ) )

 

I would 💖 Kudos 🙂 if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@rtaylor what is the business logic to which month sales you want to replace with what-if parameter value, it is not clear from your post. In your example you did it for feb but why feb, why not another month?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks @parry2k for responding.

Let's say I have table of financial projection data created by an analyst and this info is given to a director. The director now wants to see this same results but 3000 in sales february. Because a refresh would take too long. I would like to use
a what if parameter to replace the value.

 

February is just a random month. It could be any month. Also the syntax I wrote in my earlier example was just shorthand.

@rtaylor it is not very clear, are we replacing all month values by what-if parameter or there is a logic which month with have what-if parameter. Does it make sense ?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k,

 

Okay I understand.

 

The end user should be able to select any month and replace that value with a what if parameter.

 

 

Below is what I have so far. I didn't want to post this because right now I'm focused replacing the value for one deminsion with a what if parameter.

 

Var yearselect1 = What_if_Year_End_Year_Select_1[What_if_Year_End_Year_Select_1 Value]
Var treatas1 = INTERSECT(values(ENTRY_Financial_Statement_Entry[Budget_Summary_Line]),values(W_Choice_Year_End_Choice_1[Budget_Summary_Line]))
Var treatasdate1 = TREATAS(values(W_Choice_Year_End_Month_Choice_1[MonthNameShort_FiscalYear]),'Date'[MonthNameShort_FiscalYear])
Var catamount1 = What_if_Year_End_Amout_1[What_if_Year_End_Amout_1 Value]*10000
Var calctreatas1 = calculate(ProjAmout,'Date'[FiscalYear] = yearselect1,treatas1,treatasdate1)* calculate(percenttotalcalc,treatas1,treatasdate1)
Var calctreatasnodate1 = calculate(ProjAmout,'Date'[FiscalYear]=yearselect1,treatas1)* calculate([Financial_Statment_Ratio],treatas1)

Return
(Financial_Projection_II]-calctreatas1)+(catamount1)

@rtaylor that is what I was looking for, selected month

 

My Measure = 
IF ( SELECTEDVALUE ( Table[Month selected by user] ) = SELECTEDVALUE ( Datatable[Month] ), [What if parameter value], SUM ( Table[Amount] ) )

 

I would 💖 Kudos 🙂 if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.