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
Anonymous
Not applicable

Compare Dates, Hour, Minute between two Data set and return Value

Hello,

 

I have two set of data as below.

 

IO.jpg

 

My need to compare the Reference (Date, Hour, Minute) with Actual Source Data (Date, Hour, Minute) and returns the Value if Date, Hour, Minute is matched.

 

Basically, the operation will have to happen like below and go on:

 

OP.jpg

 

I tried doing this with Loop and If Condition, but I couldn’t succeed. Can anyone please help or provide me a lead to make this happen!! Looking forward!! Thank you!!!

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

Hi @Anonymous 

I get a result table as below ( filter [Hour] <=5 and [Date] =2019/1/1, so that it displays more clearly)

Capture4.JPG

 

If it meets your requirement, please refer to the steps below

1. In Edit queries, in "Date" table, Add two custom column

Custom=#"Hour"

Custom.1=#"Minute"

then expand two custom columns

Capture5.JPG

 

 

2.

In "Date" table,

select "Date", 'Custom.Hour", "Custom.1.Minute" , then "Add column"->Merge column(Separator is "-" in my example)

Then in "Actual Source Table", 

select "Date", 'Hour", "Minute" , then "Add column"->Merge column(Separator is "-" too)

 

3.

In "Date" table, merge queries, then expand "Merged 2" column from "Source table"

Capture6.JPG

 

4. Close&&apply, create a cacluated column

count = CALCULATE(COUNTROWS('Date'),FILTER(ALLEXCEPT('Date','Date'[Date]),[Actual Source Table.Merged2]<>BLANK()))

Best Regards
Maggie

 

Community Support Team _ Maggie 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

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Is this problem sloved? 
If it is sloved, could you kindly accept it as a solution to close this case?
If not, please let me know.
 
Best Regards
Maggie
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

I get a result table as below ( filter [Hour] <=5 and [Date] =2019/1/1, so that it displays more clearly)

Capture4.JPG

 

If it meets your requirement, please refer to the steps below

1. In Edit queries, in "Date" table, Add two custom column

Custom=#"Hour"

Custom.1=#"Minute"

then expand two custom columns

Capture5.JPG

 

 

2.

In "Date" table,

select "Date", 'Custom.Hour", "Custom.1.Minute" , then "Add column"->Merge column(Separator is "-" in my example)

Then in "Actual Source Table", 

select "Date", 'Hour", "Minute" , then "Add column"->Merge column(Separator is "-" too)

 

3.

In "Date" table, merge queries, then expand "Merged 2" column from "Source table"

Capture6.JPG

 

4. Close&&apply, create a cacluated column

count = CALCULATE(COUNTROWS('Date'),FILTER(ALLEXCEPT('Date','Date'[Date]),[Actual Source Table.Merged2]<>BLANK()))

Best Regards
Maggie

 

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

Greg_Deckler
Super User
Super User

Check out the function LOOKUPVALUE, that should be all you need. I do not see a need for looping here.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks for the HeadsUp!!!

 

Actually I need to compare the Date, Hour & Minute and get the Value and count as well. Like how much value for Date 1/1/2019, 1/2/2019 and so on. It doesn't end up with 3 Dates. It may keep going for a year!! That's why i thought of Loop and If condition.

 

But I had an idea like below:

 

Output = Count of (Lookup( Reference Value, Reference Date = Source Date, Reference Hour = Source Hour, Reference Minute = Source Minute, "0", "1"))

 

Please let me know if the above concept works!! First it will look up the Date,Hour,Minute and then return a Value.

That Value will be counted as I am using Count function.

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.

Top Solution Authors
Top Kudoed Authors