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
Arnoh
Helper III
Helper III

what if parameter

Hello i have a question about the what if parameter.

 

I would like to create a colum base on this dax formula:

 

Kolom = if(Parameter[Waarde van Parameter] = 1;Boek_ink_verk_openstaand[factuur datum];Boek_ink_verk_openstaand[factuur datum])

 

So if the parameter value is selected as '1' it should return Boek_ink_verk_openstaand[factuur datum] else

Boek_ink_verk_openstaand[factuur datum]. 

 

But it doensn't work!

 

Thanx

6 REPLIES 6
Eric_Zhang
Employee
Employee

What-if parameter actually works in a slicer, and the slicer doesn't affect any calculated column/table, see why.

 

Just follow the suggestion in above post, create a measure instead of calculated column.

Hello,

 

I am looking for a way to create a parameter where from i can select one option to make a measure whitch shows a date based on te selected parameter. 

 

I try to explain. 

 

The parameter should have the following options:

- date based on invoice date

- date based on pay date

- date based on expected pay date

 

 

I would like to have a calculated collum or a measure witch showes the date based on the selection. 

 

Is this possible?

 

Thanx

 

 

add new  table called "Date Slicer" with 3 records:

 

Id   Choose Date

1    date based on invoice date

2    date based on pay date

3   date based on expected pay date

 

Add "Choose Date" as slicer

 

Add a measure

 

Date based on slicer = 
var selectedId = SELECTEDVALUE('Date Slicer'[Id], BLANK()) 
return
if(selectedId = BLANK(), BLANK(),
	if(selectedId = 1, FIRSTDATE(Table[InvoiceDate]),
		if(Selectedid = 3, FIRSTDATE(Table[PayDate]),
			FIRSTDATE(Table[ExpectedPayDate])
		)
	)
)

"Date Based on Slicer" measure will show the date based on option selected in Slicer, if more than one option selected or no option selected it will return blank and that you can change in your measure (red) if you want different behaviour.

 

 



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.

Thanx for your input. 

 

I have created the slicer and the measure. 

 

I have another question: 

 

i also created a date table with the function calenderauto. In this table i added the weeknumber. 

 

I would like to link te selected datevalue from the sollution you provided to the date table i created. Colums can be selected the but i can't select a measure to make te link between the two tables.

 

Can you help me with this?

 

Greet

Hey @Arnoh

 

Yes you cannot create relationship between measure, here is what you need to do, you have to create relationship with your 3 original dates,  when you will create those relationship, it wil make active and other two inactive. I'm assuming you Active relationship with date is on invoicedate and other two are inactive.

 

For example based on selected slicer, you want to sum amount, so this is what you need to achieve it:

 

add following measure (although all this can be done in one measure as well)

 

Total based on invoice date = SUM(Table[Amount])

Total based on paydate = Calculate(Sum(Table[Amount]), Userelationship(Table[PayDate], Calendar[Date]))

Total based on expected pay date = Calculate(Sum(Table[Amount]), Userelationship(Table[ExpectedPayDate], Calendar[Date]))

Total Amount based on selected date =
var selectedId = SELECTEDVALUE('Date Slicer'[Id], BLANK()) 
return
if(selectedId = BLANK(), BLANK(),
	if(selectedId = 1, [Total Based on invoice date],
		if(Selectedid = 2, [Total Based on Pay Date],
			[Total Based on expected pay date]
		)
	)
)


 

 



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
Super User
Super User

What if parameter is a measure and you have to add a measure not column.



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.