Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

DAX Calculation with multiple rules

Hi there,
I am looking create a measure "Quote Waiting Customer Review" with multiple rules.

The rules are below.
CANCELLED is a date field.
INVOICED is a date field.

LGI_MAINTENANCE is a date field.

SENT_TO_MIN is a date field.

COMPLETED is a date field.

QUOTED is a date field.
STATUS_DATE is a date linked to calender. I need to call this Var STATUS_DATE = SELECTEDVALUE(Calendar[Date]) in the DAX

COUNT where (CANCELLED is null or CANCELLED >= :STATUS_DATE)

and (INVOICED is null or INVOICED >= :STATUS_DATE)

and (LGI_MAINTENANCE is null or LGI_MAINTENANCE >= :STATUS_DATE)

and (SENT_TO_MIN is null or SENT_TO_MIN >= :STATUS_DATE)

and (COMPLETED is null or COMPLETED >= :STATUS_DATE)

and (ACCEPTED is null or ACCEPTED >= :STATUS_DATE)

and (QUOTED < :STATUS_DATE)

 

Any help would be appreciated.

1 ACCEPTED SOLUTION

@Anonymous did you copy and paste my code into your PBIX and just change the table name from 'Table' to whatever your table is called?

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

View solution in original post

12 REPLIES 12
Anonymous
Not applicable

It has not been solved. Sorry i was meant to click reply and instead clicked accept as solution. Is there any way to reopen?

TheoC
Super User
Super User

Hi @Anonymous 

 

You can use the SWITCH function to achieve this.  

 

 

New Measure =

VAR _StatusDate = SELECTEDVALUE ( 'Calendar'[Date] )

RETURN 

SWITCH (
	TRUE () ,
		'Table'[CANCELLED] = "" || 'Table'[CANCELLED] >= _StatusDate , 1 ,
		'Table'[INVOICED] = "" || 'Table'[INVOICED] >= _StatusDate , 1 ,
		'Table'[LGI_MAINTENANCE] = "" || 'Table'[LGI_MAINTENANCE] >= _StatusDate , 1 ,
		'Table'[SENT_TO_MIN] = "" || 'Table'[SENT_TO_MIN] >= _StatusDate , 1 ,
		'Table'[COMPLETED] = "" || 'Table'[COMPLETED] >= _StatusDate , 1 ,
		'Table'[ACCEPTED] = "" || 'Table'[ACCEPTED] >= _StatusDate , 1 ,
		'Table'[QUOTED] < _StatusDate , 1 , 
		0 )

 

 

Using the above, you can then COUNTROWS / FILTER = 1 on the above.


Hope this helps 🙂

 

Theo

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Anonymous
Not applicable

Hi Theo,

Thanks for your reply.

'Table'[Cancelled] 'Table'[Invoiced] etc, are all dates in the same table.

How when i write the DAX i cant seem to select or find the these fields?

Thanks

@Anonymous did you copy and paste my code into your PBIX and just change the table name from 'Table' to whatever your table is called?

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Anonymous
Not applicable

Yeah I did

@Anonymous can you screen shot what the measure you used?

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

@Anonymous I am not sure how to reopen a post, but I promise I will work with you until it's resolved 🙂

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Anonymous
Not applicable

Thanks Theo! 

Please see below

jz5147_0-1635280455753.png

jz5147_1-1635280462714.png

 

@Anonymous you need to change the all of the 'Table' to whatever the table name is called. For example, if the 'Table' is "AR_MANAGER BI_DASHBOARD_SRC_VW" then you need to replace the 'table' with "AR_MANAGER BI_DASHBOARD_SRC_VW". Try the below:

 

New Measure =

VAR _StatusDate = SELECTEDVALUE ( 'Calendar'[Date] )

RETURN 

SWITCH (
	TRUE () ,
		'AR_MANAGER BI_DASHBOARD_SRC_VW'[CANCELLED] = "" || 'AR_MANAGER BI_DASHBOARD_SRC_VW'[CANCELLED] >= _StatusDate , 1 ,
		'AR_MANAGER BI_DASHBOARD_SRC_VW'[INVOICED] = "" || 'AR_MANAGER BI_DASHBOARD_SRC_VW'[INVOICED] >= _StatusDate , 1 ,
		'AR_MANAGER BI_DASHBOARD_SRC_VW'[LGI_MAINTENANCE] = "" || 'AR_MANAGER BI_DASHBOARD_SRC_VW'[LGI_MAINTENANCE] >= _StatusDate , 1 ,
		'AR_MANAGER BI_DASHBOARD_SRC_VW'[SENT_TO_MIN] = "" || 'AR_MANAGER BI_DASHBOARD_SRC_VW'[SENT_TO_MIN] >= _StatusDate , 1 ,
		'AR_MANAGER BI_DASHBOARD_SRC_VW'[COMPLETED] = "" || 'AR_MANAGER BI_DASHBOARD_SRC_VW'[COMPLETED] >= _StatusDate , 1 ,
		'AR_MANAGER BI_DASHBOARD_SRC_VW'[ACCEPTED] = "" || 'AR_MANAGER BI_DASHBOARD_SRC_VW'[ACCEPTED] >= _StatusDate , 1 ,
		'AR_MANAGER BI_DASHBOARD_SRC_VW'[QUOTED] < _StatusDate , 1 , 
		0 )

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Anonymous
Not applicable

Thanks Theo

I understand that but even when i do this, the field [CANCELLED] ETC is greyed out and cant be select. I have checked that those fields are in the same table as where i am creating the meausre. Its actually not picking up the Field when typing the DAX

 

jz5147_1-1635284486154.png

 

@Anonymous my apologies, the screenshot has helped my understanding of the problem.  

 

If you were to delete the measure, then re-write it from scratch (instead of copying and pasting), are you able to see columns / fields after the Table name?  For example, if you type 'AR_MANAGER BI_DASHBOARD_SRC_VW' does it give you any columns/fields after it as options to select?

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Anonymous
Not applicable

Hi Theo

I have also tried this, not for the same metric above and not as complex.

 

STRIKE RATE = VAR _StatusDate = SELECTEDVALUE ( 'Calendar'[Date] )
RETURN

CALCULATE(COUNT('AR_MANAGER BI_DASHBOARD_SRC_VW'[ACCEPTED]),FILTER('AR_MANAGER BI_DASHBOARD_SRC_VW',
('AR_MANAGER BI_DASHBOARD_SRC_VW'[ACCEPTED] >= _StatusDate) && ( 'AR_MANAGER BI_DASHBOARD_SRC_VW'[CANCELLED] >= _StatusDate || 'AR_MANAGER BI_DASHBOARD_SRC_VW'[QUOTED] <> "null" )
))

I get this error
jz5147_0-1635283736480.png

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.