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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
MAAbdullah47
Helper V
Helper V

Measuring the updated fair price for selling cars website

Dear All,

 

A second-hand car selling website wants to manage the sales business by suggesting the following business process improvements In his local data base to help them in doing visualization in the future to compare car sales prices.

 

Assuming we have 3 features in the local car data base:

 

Car Year Model: Numeric (String) --> The year model was car manufactured.

Adv Date: Date --> The date was the owner(customer) Make AD for selling his Car.

Price: Numeric--> The Original Car Price.

 

Let's assume the Following Scenario the customer has:

 

Car Original Price : 100,000 $

Car Manufacturing Year Model: 2014

Sale Ad date (Date when customer place AD for selling the car): 2016/10/31

Today Year: Current Year (2017)

 

 

I need to create 2 columns (preferred with DAX if possible)  based on the following equations:

 

Column (1) Price On The AD Date:   Original Price – 10% Of The Original Price for every Car year model Till The Year of the AD Date e.g.:

Car Year Manufacturing : 2014 (100,000 $).

So The Price On AD Date Should be 80,000 $ (If The Difference between Year AD Date – Car Year Model ) <= 8 Years.

Column (2) Price In the current date (Year):

Assume We Are On 2017  So the price should be: 70,000$ (Original Price – 10% Of The Original Price for every Car year model Till The current year date).

 

Thank You All

 

1 ACCEPTED SOLUTION

@MAAbdullah47,

You can check the DAX in attached PBIX file, if you have any questions about the DAX, please let me know.
1.JPG



Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

17 REPLIES 17
vanessafvg
Super User
Super User

@MAAbdullah47

 

 

Column (1) Price On The AD Date:   Original Price – 10% Of The Original Price for every Car year model Till The Year of the AD Date e.g.:

Car Year Manufacturing : 2014 (100,000 $).

So The Price On AD Date Should be 80,000 $ (If The Difference between Year AD Date – Car Year Model ) <= 8 Years.

 

column1 =
VAR modelyear = modelyear
VAR advyear = advyear
VAR noofyears = ( advyear - modelyear )
VAR originalamt =
    MIN ( originalprice )
VAR diff =
    CALCULATE ( DIVIDE ( 10, originalamt ) )
RETURN
    originalamt
        - ( nofyears * diff )

 

havent tested it so not sure if it works but you get the idea?

 

 

  

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




If you work In DAX I create new measure when I write the word (VAR) it not accept it list (VAR.S , VAR.P, VARX.S, VARX.P)

Not accepting the word VAR?

Is it also the same for column 2?

VAR modelyear = modelyear
VAR advyear = advyear

 

Assume The name of the fields in Db =  Model_Car_Year , Ad_year

 

Shall I put it like this :

VAR modelyear = Db[Model_Car_Year]
VAR advyear =  Db[Ad_year]

 

Does it needs to say it is a type of the Var (Numeric or date ,....etc).

 

 

@MAAbdullah47 are you doing this in power bi?

 

no, you dont need to declare any types

 

you mean table name db? 

 

you just slap it all into a new measure, thats why you using thar variables

 

just create new measure and put all the code in





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Also, I have small problem the Year ADv Model is text and Car Model as well, so how to deal with it in making Year difference?

 

Sorry, Just By Logic how the variables get the data from?

 

In Addition, I note it is labeled by (column1) but in your reply, you said the measure , is it measure or column?

 

@MAAbdullah47 column 1 was just a reference to your name, it is a measure

 

not sure i understand what you asking?  power bi will calculate the measure based on what you place on your visual so if you place all the details on for example a table, thats the level the calculation will be done at, it really depends on what the granularity is that you are placing on your visual, makes sense/

 

give a bash and see what happens.  once you attempt it it will become more clear

 

 

 

 

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Assuming we have 3 features in the local car data base:

 

Car Year Model: Numeric (String) --> The year model was car manufactured.

Adv Date: Date --> The date was the owner(customer) Make AD for selling his Car.

Price: Numeric--> The Original Car Price.

 

Is  this sentence is very difficult??!!!

 

In the report I have 3 columns with the above names so what is the difficult thing of this you don't understand it?!!!!

 

@MAAbdullah47  i have already given you the code as you would place it in a measure

 

 

but honestly i think you are just being rude now and you know what find someone else to you help you because you are completely out of order.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Sorry About what you said I don't want to respond cuz I'm confident every reply I send it with the word (sorry) so where the rude behavior is (Sorry) rude behavior? the problem you are (bumptious) in your answers. 

@MAAbdullah47,

You can check the DAX in attached PBIX file, if you have any questions about the DAX, please let me know.
1.JPG



Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank You so much this is a logical solution.

Thank You So Much I'll try to test it soon and get back to you, appreciating your help.

Sorry Your Solution is totally confusing, I'm still beginner and you assuming that I'm advanced expert in power bi , If you want to help please help by considering the level of the person who sends the question, I think the question is very clear but I'm not sure which point you didn't understand , totally I cannot understand what you explain for the question I'm fully confident that any one can understand it.

 

Thank you  

@MAAbdullah47 

 i am not assuming anything, tell me what you are struggling with specifically

 

 

--->click on create new measure

---->adjust the code to the appropriate naming of the columns of your model  if the ones i put there is wrong

 

ask specific questions about what you are struggling with and give screen shots so i can see exactly where the issue is, i am not being funny but i cannot tell from a few words on a page what you are struggling with specifically, id like to be telepathic but unfortunately i am not  Smiley Wink





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




I did Copy PasteI did Copy Paste

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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