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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Syndicate_Admin
Administrator
Administrator

Dax: how to make a condition between two dates met

Good, the title is half vague because I honestly do not know how to put it in a few words, I tell you:

I have two tables:
-DATE-->where as the name implies, are the dates, using the "Day" column as the date ratio for everything
-DATA--> I have my records

In data I have the following table:

NUMBERID
Carlos1
Marten2
Monica3

Let's pretend that, if the ID=1, the hair color is "blond", ID=2 "red", in case it is neither 1 nor 2, it is "brown". So, I want the color to appear as a value in an array, column the date and the rows the name, it would be something like this:

2022-01 2022-02 2022-03 2022-04 2022-05
Carlos Rubio Rubio Rubio colorado colorado
Marta colorado coloroado coloroado coloroado coloroado
Monica chestnut chestnut chestnut chestnut chestnut chestnut


As you may have noticed, I put two words in bold, that's because in the third month of March, Carlos changed to Rubio, and it's what I can't get out of. So far, I'm trying something like:

Spoiler

ColorPelo =

where selectcolor=VALUE(SELECTEDVALUE('Data'[NUMBER]))
where es_rubio=selectcolor=1
where es_colorado=selectcolor=2
where es_castaño=NOT(es_rubio || es_colorado)
where color=is_poc || is_experiencias || is_demand
return
color

With that, it effectively brings me the colors corresponding to each ID, in a nutshell, it brings me the table above without "colorado" in Juan.
The problem is that I can't get him to bring me "if what I see is after March 15, 2022, Carlos is chestnut."
My idea was with logical operators, example:

Test=
var startdatte=date(2022, 03, 15)

var hoy=today()
return
if(today>startdate), "yes", "no")

-->this should return me, all record after March 3 a "yes" and previous a "no", and then I could use this logic to give me like the table I put above ... but I don't have any results.

Any help would be welcome, thank you very much

1 ACCEPTED SOLUTION

It is literally not a riddle, in my original post I explained everything there was, then you asked for less, I sent a summary. I also work and try to help whenever I can in things that I know like Python and SQL, that's not why I'm going to be an about it.

Likewise, I managed to do it, I leave what I did for anyone who has the same doubt as me. I changed the names of some tables and columns so it becomes more understandable for those who read it and can replicate it wherever they look, I hope it helps:

Spoiler
NombreMedida=
where IdDato=VALUE(RELATED('Data'[ID]))
the value because the ID was in text format for a change I made, otherwise it is not necessary
where NombreDato=SELECTEDVALUE('Data'[Number])
where selectdate=CALCULATE(Max('Date - Day'[Date]), all('Date - Day'[Date]))
where startdate=DATE(2022, 03, 15)

where CarlosisRubio=NombreDato="Carlos" && startdate>selectdate

where is_colorado=IdDato=[I write desired ID] || IdDato=I type ID desired || etc
where is_castano=IdDato=[I write DESIRED ID] || etc
where is_rubio=NOT(is_colorado|| is_castano)

return

if(CarlosisRubio, "Blond",
if(is_colorado, "Colorado",
if(is_rubio, "Blond",
if(is_castano, "Chestnut", "Error"))))

View solution in original post

4 REPLIES 4
speedramps
Super User
Super User

I want to help, but I can't be bothered scrolling up and down between your message to try fathom out what help you need.

 

If you ard too busy or lazy to simply describe your problem in one block with example impurt and output data, then I decline to help.

 

There are lots of other members on this forum who describe their problems well and are rewarded with quick replied.

 

Don't make it a riddle. Keep it simple please. Rember we are unpaid volunteers with other full time jobs.

 

If you want free help then provide the infomation clearly. Thank you

 

Look foward to helping you when the above information is forthcoming.

It is literally not a riddle, in my original post I explained everything there was, then you asked for less, I sent a summary. I also work and try to help whenever I can in things that I know like Python and SQL, that's not why I'm going to be an about it.

Likewise, I managed to do it, I leave what I did for anyone who has the same doubt as me. I changed the names of some tables and columns so it becomes more understandable for those who read it and can replicate it wherever they look, I hope it helps:

Spoiler
NombreMedida=
where IdDato=VALUE(RELATED('Data'[ID]))
the value because the ID was in text format for a change I made, otherwise it is not necessary
where NombreDato=SELECTEDVALUE('Data'[Number])
where selectdate=CALCULATE(Max('Date - Day'[Date]), all('Date - Day'[Date]))
where startdate=DATE(2022, 03, 15)

where CarlosisRubio=NombreDato="Carlos" && startdate>selectdate

where is_colorado=IdDato=[I write desired ID] || IdDato=I type ID desired || etc
where is_castano=IdDato=[I write DESIRED ID] || etc
where is_rubio=NOT(is_colorado|| is_castano)

return

if(CarlosisRubio, "Blond",
if(is_colorado, "Colorado",
if(is_rubio, "Blond",
if(is_castano, "Chestnut", "Error"))))
speedramps
Super User
Super User

We want to help you but your description is too vaugue.

Please write it again clearly.

 

Please DONT copy and paste your DAX that does not work and expect us to fathom out how it should work !

Just tell us the functonal requirements and lets us provide the DAX thank you 😀

 

Provide example input data as table text (not a screen print) so we can import the data to build a soution for you.

Also provide the example desired output, with a clear description of the process flow.

Take care to use the same table and field names in the input, output and description so we can understand your problem and help you.

You example has no dates in the table.  So we cant slide, dice, group or aggregate it by date 🙄

 

You will get a quick response if you put time and effort into writing clear problem descriptions.

Vaugue descriptions waste your time and ourtime.

Look foward to helping you when the above information is forthcoming.

Sorry, I tried to put most of the information so that it is better understood, I will summarize it:

I want an event, after a certain date, to change value. Continuing with the example above, if until month 3 Carlos was "blond", from month 4 he became "colorado".

The tables used are: 'Data' (which is where these values are located) and 'Date' (the table where all the dates are). I manage to do everything except, that after that date the value changes from blond-->colored.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors