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

How to build condition?

Hi all

 

I have in formula this condition:

FILTER
	(CROSSJOIN(Downtime;'HourOfDay');
		HOUR(Downtime[Start])<='HourOfDay'[Hour of Day]&&HOUR     
                (Downtime[End])>='HourOfDay'[Hour of Day]
      )

I need to add additnal lines to make it working as I want, but don't know how to build DAX formula.

 

I want to add those lines into filter table.

Many thanks

Michal

DAY(Downtime[Start])<>DAY(Downtime[End]) then show lines where HourOfDay'[Hour of Day]>=HOUR(Downtime[Start])
plus
DAY(Do
wntime[Start])<>DAY(Downtime[End]) then show lines where HourOfDay'[Hour of Day]<=HOUR(Downtime[End])
1 ACCEPTED SOLUTION

@MichalSimota,

 

Just use the logical OR operator (||) to combine expressions.

https://docs.microsoft.com/en-us/dax/dax-operator-reference#logical-operators

Community Support Team _ Sam Zha
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
AlB
Super User
Super User

Hi @MichalSimota

 

Is this correct? You are showing the same (in red) on both conditions

 

DAY(Downtime[Start])<>DAY(Downtime[End]) then show lines where HourOfDay'[Hour of Day]>=HOUR(Downtime[Start])
plus
DAY(Do
wntime[Start])<>DAY(Downtime[End]) then show lines where HourOfDay'[Hour of Day]<=HOUR(Downtime[End])

 

Hi

 

What I need to achieve by this is to show downtime for each hour(not just for start or end hour) so I need to filter all lines which are between start and end hour. It's done by fist formula:

HOUR(Downtime[Start])<='HourOfDay'[Hour of Day]&&HOUR (Downtime[End])>='HourOfDay'[Hour of Day]

 

But because some downtimes continue from one day to another, just this formula is not enough for such downtimes( when it start at 23:00 and finish at 01:00) So for those cases I need to add condittion to see also those hours. My idea was to add those conditions, so I tried it several times to build fomula but it did not work.

 

So Idea was to add comparison of days: DAY(Downtime[Start])<>DAY(Downtime[End]) and if this condition is walid, than I need to filter lines wich have this HourOfDay'[Hour of Day]>=HOUR(Downtime[Start]) or this HourOfDay'[Hour of Day]<=HOUR(Downtime[End]) condition.

 

Thanks

Michal

@MichalSimota,

 

Just use the logical OR operator (||) to combine expressions.

https://docs.microsoft.com/en-us/dax/dax-operator-reference#logical-operators

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

@MichalSimota

Can you show the structure of your tables 'Downtime' and  'Hour of Day'? or share the pbix?

It'd be easier to come up with a solution with that info

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.