cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Meraki_jeet
Frequent Visitor

Hello All, How to compare Date & Time using the text field. Dax or Measure?

Hi Everyone,

Could someone please help me out with DAX for below as I am stuck in middle. Below is my sample data

                      Resource Name                                  DIS_scheduled                       Scan Time
TEST_CONCURRENT_SCANS_ORA_SM_8       SM_PROFILING_PRD           12/26/2023 14:30
TEST_CONCURRENT_SCANS_ORA_SM_7       SM_PROFILING_PRD           12/26/2023 14:30
TEST_CONCURRENT_SCANS_ORA_SM_6       SM_PROFILING_PRD           12/26/2023 14:30
TEST_CONCURRENT_SCANS_ORA_SM_5       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_4       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_3       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_2       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_1       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_MD_5      MD_PROFILING_PRD           12/27/2023 12:00
TEST_CONCURRENT_SCANS_ORA_MD_4      MD_PROFILING_PRD           12/27/2023 12:00
TEST_CONCURRENT_SCANS_ORA_MD_3      MD_PROFILING_PRD           12/27/2023 13:30
TEST_CONCURRENT_SCANS_ORA_MD_2      MD_PROFILING_PRD           12/27/2023 15:00
TEST_CONCURRENT_SCANS_ORA_MD_1      MD_PROFILING_PRD           12/27/2023 11:00
TEST_CONCURRENT_SCANS_ORA_LG_3       LG_PROFILING_PRD             12/28/2023 13:00
TEST_CONCURRENT_SCANS_ORA_LG_2      LG_PROFILING_PRD              12/28/2023 11:00
TEST_CONCURRENT_SCANS_ORA_LG_1      LG_PROFILING_PRD              12/28/2023 9:00
TEST_CONCURRENT_SCANS_ORA_XL_2       XL_PROFILING_PRD              12/29/2023 10:00
TEST_CONCURRENT_SCANS_ORA_XL_1       XL_PROFILING_PRD              12/30/2023 7:00
TEST_CONCURRENT_SCANS_ORA_SM_8     SM_PROFILING_PRD             12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_7     SM_PROFILING_PRD             12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_6     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_5     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_4     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_3     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_2     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_1     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_MD_5     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_MD_4     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_MD_3     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_MD_2     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_MD_1     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_LG_3      LG_PROFILING_PRD            12/31/2023 9:00
TEST_CONCURRENT_SCANS_ORA_LG_2      LG_PROFILING_PRD            12/31/2023 9:00
TEST_CONCURRENT_SCANS_ORA_LG_1      LG_PROFILING_PRD            12/31/2023 9:00
TEST_CONCURRENT_SCANS_ORA_XL_2       XL_PROFILING_PRD            12/31/2023 7:00
TEST_CONCURRENT_SCANS_ORA_XL_1       XL_PROFILING_PRD            12/31/2023 7:00

 

so here 

>> any resource should not be scheduled(i.e. Scan_time column above) if there are resources already scheduled upto 2 hrs before for DIS_scheduled = "SM_PROFILING_PRD"

>> any resource should not be scheduled if there are resources already scheduled upto 5 hrs before for DIS_scheduled = "MD_PROFILING_PRD"

>> any resource should not be scheduled if there are resources already scheduled upto 10 hrs before for DIS_scheduled = "LG_PROFILING_PRD"
>> any resource should not be scheduled if there are resources already scheduled upto 24 hrs before for DIS_scheduled = "XL_PROFILING_PRD"

So for Example, For DIS_scheduled = "SM_PROFILING_PRD", if  2 Resources have Scan_time on 12/31/2023 14:30 but there are already  resources having Scan_time at 12/31/2023 13:00 which is an issue as no resource should be scheduled 2hrs before

I have to use Scan_Time column to check above conditions and create new column with output as "Issue" or "No issue"
Please let me know if more data is required.

 

Thanks 

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

Hi @Meraki_jeet ,

 

Please try:

Column = 
var _a = SWITCH([DIS_scheduled],
                "SM_PROFILING_PRD",[Scan Time]-TIME(2,0,0),
                "MD_PROFILING_PRD",[Scan Time]-TIME(5,0,0),
                "LG_PROFILING_PRD",[Scan Time]-TIME(10,0,0),
                "XL_PROFILING_PRD",[Scan Time]-TIME(24,0,0))
var _c = COUNTX(FILTER('Table',[Scan Time]>=_a&&[Scan Time]<EARLIER('Table'[Scan Time])),[Resource Name])
return IF(_c<>BLANK(),"Issue","No issue")

Final output:

vjianbolimsft_0-1686720404641.png

Best Regards,

Jianbo Li

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

6 REPLIES 6
v-jianboli-msft
Community Support
Community Support

Hi @Meraki_jeet ,

 

Please try:

Column = 
var _a = SWITCH([DIS_scheduled],
                "SM_PROFILING_PRD",[Scan Time]-TIME(2,0,0),
                "MD_PROFILING_PRD",[Scan Time]-TIME(5,0,0),
                "LG_PROFILING_PRD",[Scan Time]-TIME(10,0,0),
                "XL_PROFILING_PRD",[Scan Time]-TIME(24,0,0))
var _c = COUNTX(FILTER('Table',[Scan Time]>=_a&&[Scan Time]<EARLIER('Table'[Scan Time])),[Resource Name])
return IF(_c<>BLANK(),"Issue","No issue")

Final output:

vjianbolimsft_0-1686720404641.png

Best Regards,

Jianbo Li

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 @v-jianboli-msft . Cheers!! It did worked.

Meraki_jeet
Frequent Visitor

Anyone can urgently  help please with the solution?

Meraki_jeet
Frequent Visitor

Hi @Greg_Deckler , Do you have any idea on how I can do the above. Please let me know if any

Meraki_jeet
Frequent Visitor

 

 

Hi @Greg_Deckler  , Thanks.  Please find  data below,

                      Resource Name                                  DIS_scheduled                       Scan Time
TEST_CONCURRENT_SCANS_ORA_SM_8       SM_PROFILING_PRD           12/26/2023 14:30
TEST_CONCURRENT_SCANS_ORA_SM_7       SM_PROFILING_PRD           12/26/2023 14:30
TEST_CONCURRENT_SCANS_ORA_SM_6       SM_PROFILING_PRD           12/26/2023 14:30
TEST_CONCURRENT_SCANS_ORA_SM_5       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_4       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_3       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_2       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_1       SM_PROFILING_PRD           12/26/2023 13:00
TEST_CONCURRENT_SCANS_ORA_MD_5      MD_PROFILING_PRD           12/27/2023 12:00
TEST_CONCURRENT_SCANS_ORA_MD_4      MD_PROFILING_PRD           12/27/2023 12:00
TEST_CONCURRENT_SCANS_ORA_MD_3      MD_PROFILING_PRD           12/27/2023 13:30
TEST_CONCURRENT_SCANS_ORA_MD_2      MD_PROFILING_PRD           12/27/2023 15:00
TEST_CONCURRENT_SCANS_ORA_MD_1      MD_PROFILING_PRD           12/27/2023 11:00
TEST_CONCURRENT_SCANS_ORA_LG_3       LG_PROFILING_PRD             12/28/2023 13:00
TEST_CONCURRENT_SCANS_ORA_LG_2      LG_PROFILING_PRD              12/28/2023 11:00
TEST_CONCURRENT_SCANS_ORA_LG_1      LG_PROFILING_PRD              12/28/2023 9:00
TEST_CONCURRENT_SCANS_ORA_XL_2       XL_PROFILING_PRD              12/29/2023 10:00
TEST_CONCURRENT_SCANS_ORA_XL_1       XL_PROFILING_PRD              12/30/2023 7:00
TEST_CONCURRENT_SCANS_ORA_SM_8     SM_PROFILING_PRD             12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_7     SM_PROFILING_PRD             12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_6     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_5     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_4     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_3     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_2     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_SM_1     SM_PROFILING_PRD            12/31/2023 13:00
TEST_CONCURRENT_SCANS_ORA_MD_5     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_MD_4     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_MD_3     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_MD_2     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_MD_1     MD_PROFILING_PRD          12/31/2023 11:00
TEST_CONCURRENT_SCANS_ORA_LG_3      LG_PROFILING_PRD            12/31/2023 9:00
TEST_CONCURRENT_SCANS_ORA_LG_2      LG_PROFILING_PRD            12/31/2023 9:00
TEST_CONCURRENT_SCANS_ORA_LG_1      LG_PROFILING_PRD            12/31/2023 9:00
TEST_CONCURRENT_SCANS_ORA_XL_2       XL_PROFILING_PRD            12/31/2023 7:00
TEST_CONCURRENT_SCANS_ORA_XL_1       XL_PROFILING_PRD            12/31/2023 7:00

Greg_Deckler
Super User
Super User

@Meraki_jeet Can you post that sample data as text?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors