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
mwadhwani
Kudo Kingpin
Kudo Kingpin

Complex DAX for Time related data

Hello Experts ,

I have scenario where I want to plot two measure in line graph/Table.

Below is the reference data:

DataReference.PNG 

For example: For Mid=45 ,F_Value=894. So I need to go back 894 seconds i.e 14.9 mins and I have to count F_Value <=5 for Mid=1 between Process time of 894 (i.e 04:00:00 in above Data Reference) and 14.9 mins back (approx 03:45:00)
And I want to plot against 894.

 

Similarly I want all F_value of Mid=45 on X-axis and Count of F_Value<=5 for Mid=1 against it.

I am not sure whether it is possible using Dax or not.

Note: Process Time column has sample data.You can input if required. 

 

Any help would be highly appreciated.

 

 

--Mayur

4 REPLIES 4
v-qiuyu-msft
Community Support
Community Support

Hi @mwadhwani,

 

You can create calculated columns below: 

F_Minu = ROUND(Table1[F_Value]/60,0)

F_Time = 'Table1'[Time] -TIME(0,[F_Minu],0)

 

Then create a measure below: 

Measure = var mint=MAX('Table1'[F_Time])
var maxt=MAX('Table1'[Time])
var currF=VALUE(RIGHT(MAX('Table1'[F_Minu]),1))
var currM=VALUE(LEFT(MAX('Table1'[F_Minu]),1))
return
CALCULATE(COUNTROWS('Table1'),FILTER(ALL(Table1),'Table1'[Time]>=mint && 'Table1'[Time]<=maxt && Table1[F_Value]<=currF && Table1[Mid]=currM))

 

q6.PNG

 

You can download the attached pbix file to check if it meet your requirements. 

 

Best Regards,
Qiuyun Yu

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

Thanks a ton @v-qiuyu-msft. It indeed helped me and took very close to my desired output.

In the pbix, I see output only for value 894.

I need all F_Value on x-axis whose Mid=45.

As we have a F_value=7895 and F_Minu calucalted as 132. If we go 132 mins back from respective (i.e 02:00:00) I see two F_Value<=5(whose Mid=1).
But I see only 894 on x-axis and not 7895.

 

Can you please clear my above query.

 

Thanks a lot again!!

Hi @mwadhwani,

 

As the X-axis is F_Value column, when it's 7895, F_Minu is 132 minutes, how do you compare it with F_Value and Mid, eg: F_Value<=1, Mid=2? Why it should compare like F_Value<=5(whose Mid=1). 7895 and 894 in the X-axis should be two different groups. 

 

 

Best Regards,
Qiuyun Yu

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

Thank you @v-qiuyu-msft for the reply. Your expertise is helping me to resolve my other related queries as well.
I create two columns Start Time and End Time into another table with Mid=45.
And In one table I Keep Mid=1 data.

In your pbix Measure definition has variable as Min(Time) and max(Time) which is specific for F_Value 894. I guess thas the reason I am getting only 894 on X-axis.

I am not even sure as well whether it is achievevalbe or not.

 

Thanks

 

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.