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
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
Community Champion
Community Champion

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



Follow on LinkedIn
@ 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!:
DAX For Humans

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.