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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Trying to make a formula conditional by date depending on time from current date

Hi all,

 

I am trying to implement the Excel formula in the below screenshots into DAX for use in a Power BI dashboard.

 

Here is my data, the formula, and an explanation of what the formula does:

 

If a date is over 6 days ago, I do not want to adjust its value. If a date is within 6 days of the current date but more than 2 days ago (so 3, 4, 5, or 6 days ago), I want to increase it by 11.5% each day for the number of days remaining until it hits 6 days. If a date was within the past 2 days, I want to increase it by 13% each day for the number of days remaining until it hits 6 days.

 

The formula shown below accomplishes that in Excel.

reecehodgson26_1-1657287926216.png

 

I am now trying to port the formula into Power BI. I used a formula identical to the one above, but I replaced DAYS() with DATEDIFF(). However, I get an error when trying to reference the date column, saying that "A single value for column 'Date' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I just realized the issue; I had missed part of my formula, so the nested IF statement was off. It works now! Thank you so much; I massively appreciate it.

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

You should be able to use

DATEDIFF( TODAY(), SELECTEDVALUE('Table'[Date]), DAY)
Anonymous
Not applicable

Thank you for the help. I just tried this and am no longer getting the same error, but it did cause a new issue. The results are instead blank for the new measure in the table I made

can you post the full measure definition and maybe a screenshot of the table structure?

Anonymous
Not applicable

I just realized the issue; I had missed part of my formula, so the nested IF statement was off. It works now! Thank you so much; I massively appreciate it.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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