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

Need help on a Dax Measure

Here is a table I created. I would like to create a measure that return me the first date where type is 2.

TonyGu_0-1646961965612.png

 

For example, if in the date slicer, I select Januray 2022, it will return me the earliest next date for that agent that is type 2. In this case, here are the results I want to see:

Agent        Next Date

A               2022-02-01

B               2022-03-01

 

I will really appreciate if anyone can give me some hints.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @TonyGu ,

Here are the steps you can follow:

1. Create calculated column.

Slice = FORMAT('Table'[Date],"mmmm")&" "&YEAR('Table'[Date])

2. Create measure.

Next Date =
var _select=SELECTEDVALUE('Table'[Slice])
var _currenttype=CALCULATE(SUM('Table'[Type]),FILTER(ALL('Table'),'Table'[Slice]=_select&&'Table'[Agent]=MAX('Table'[Agent])))
return
CALCULATE(MIN('Table'[Date]),FILTER(ALL('Table'),'Table'[Agent]=MAX('Table'[Agent])&&'Table'[Type]=_currenttype+1))

3. Result:

vyangliumsft_0-1647397661805.png

 

Best Regards,

Liu Yang

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

3 REPLIES 3
Anonymous
Not applicable

Hi  @TonyGu ,

Here are the steps you can follow:

1. Create calculated column.

Slice = FORMAT('Table'[Date],"mmmm")&" "&YEAR('Table'[Date])

2. Create measure.

Next Date =
var _select=SELECTEDVALUE('Table'[Slice])
var _currenttype=CALCULATE(SUM('Table'[Type]),FILTER(ALL('Table'),'Table'[Slice]=_select&&'Table'[Agent]=MAX('Table'[Agent])))
return
CALCULATE(MIN('Table'[Date]),FILTER(ALL('Table'),'Table'[Agent]=MAX('Table'[Agent])&&'Table'[Type]=_currenttype+1))

3. Result:

vyangliumsft_0-1647397661805.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Jihwan_Kim
Super User
Super User

Hi,

One of ways is creating this table in Power Query Editor before loading into the data model.

Please check the below picture and the attached pbix file's Power Query Editor.

 

Picture1.png

 

let
    Source = Data_source,
    #"Grouped Rows" = Table.Group(Table.SelectRows(Source, each ([Type] = 2)), {"Agent"}, {{"Next Date", each List.Min([Date]), type nullable date}})
in
    #"Grouped Rows"

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Whitewater100
Solution Sage
Solution Sage

Hello:

https://drive.google.com/file/d/1Ct0vWzig2dX5Q4FFG-8h0_4-tmsNRwFY/view?usp=sharing 

 

Here's one way. Theres a calculated column and measure.

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.