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
cris1196
Helper I
Helper I

How can I change value after a date in Dax?

Hello. I am having problems, I have the following table:

cris1196_0-1662589151117.png

If ID=1, the user has a house. If ID=2, you have a car. Opposite case, has a plane. The "DATA" table can be filtered with dates thanks to a table called DATE.

 

Fred, after March 15, 2022, sold his house and bought a car, consequently, he would belong to ID=2. The result I want is the following:

cris1196_1-1662589300101.png

 

I couldn't get those two values to change from house-->car

Just in case: this is what i was trying:

 

Measure =
var SelectType=value(selectedvalue('DATE'[NAME])
var is_house=SelectType=1
var is_car=SelectType=2
var is_plane=not(is_house || is_car)
//With that, I manage to select the 3 types of data that I need

var SelectNames=selectedvalue('DATA'[Name])
var StartDate=DATE(2022, 03, 15)
var SelectDay=selectedvalue('DATE'[Day])

//With this, the idea is to use it later to say "if the date is greater than StartDate, I want to [specify what I want] result"

return
if(is_house, "House",
if(is_car, if(Selectday>StartDate, if(SelectNames="Fred", "Car",
//IF it is car, then IF the date is after StartDate AND IF the name is Fred, then it is changed to "Car"
if(is_car, "Car",
if(is_plane, "Plane"
))))))

 

Until now, everything I found on the Internet was related to what they wanted to add between dates, I did not find something similar to my problem.

 

Any idea is welcome 😔




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

Hi @cris1196 ,

 

vcgaomsft_0-1662614700642.png

Is this the only table you have for original data? All sales purchase records need to be manually go through the parameters in Dax? Creating measures like this can be very difficult to maintain in code later.

 

A better solution would be to organize all buy and sell records into a fact table and create a relationship with the date column of the calendar table, so that the problem becomes much easier.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @cris1196 ,

 

vcgaomsft_0-1662614700642.png

Is this the only table you have for original data? All sales purchase records need to be manually go through the parameters in Dax? Creating measures like this can be very difficult to maintain in code later.

 

A better solution would be to organize all buy and sell records into a fact table and create a relationship with the date column of the calendar table, so that the problem becomes much easier.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

"A better solution would be to organize all buy and sell records into a fact table and create a relationship with the date column of the calendar table, so that the problem becomes much easier."

 

Yes, I did that. Much more comfortable. Thank you!

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.