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
Narendra90
Frequent Visitor

Need dax solution which will create table and caulculations

Hi Team,

I have following input data.

Narendra90_0-1685607452695.png

need following output.
Basically when we talk about Rating 2, it should pick max date of Rating 2 and minus min date of Rating 1 for Tkt1 ID.

Same with Rating 3, it should pick maximum date of rating 3 and minus minimum date of rating 2.

all this i want to achive thorugh DAX. No extra table. Thanks in advance

Narendra90_1-1685607495231.png

 

 

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

Hi  @Narendra90 ,

 

Here are the steps you can follow:

1. Create calculated column.

Output1 =
var _date1=
MAXX(    FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Rating]=EARLIER('Table'[Rating])),[New date])
var _date2=
MINX(    FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Rating]=EARLIER('Table'[Rating])-1),[New date])
var _value=
  DATEDIFF(
        _date2,_date1,DAY)
var _count=
COUNTX(  FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Rating]=EARLIER('Table'[Rating])),[Rating])
return
IF(
    'Table'[Rating]=
MINX(
ALL('Table'),[Rating]),0,
_value / _count)

2. Result:

vyangliumsft_0-1685948856347.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

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @Narendra90 ,

 

Here are the steps you can follow:

1. Create calculated column.

Output1 =
var _date1=
MAXX(    FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Rating]=EARLIER('Table'[Rating])),[New date])
var _date2=
MINX(    FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Rating]=EARLIER('Table'[Rating])-1),[New date])
var _value=
  DATEDIFF(
        _date2,_date1,DAY)
var _count=
COUNTX(  FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Rating]=EARLIER('Table'[Rating])),[Rating])
return
IF(
    'Table'[Rating]=
MINX(
ALL('Table'),[Rating]),0,
_value / _count)

2. Result:

vyangliumsft_0-1685948856347.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

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.