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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How to check a condition against Date/Time column

Hello,

I am trying to create a new measure using IF condition,

IF report[log_date] falls in Quarter 4 of the Year then calculate average of Person A,B,C else calculate average of Person A and B only.

 

 

 

 

 

IF(
    report[log_date].[DATE]>DATE(2021, 10, 01),
    CALCULATE(
        [average],
        'report'[NAME] IN {
            "PERSON A",
            "PERSON B",
            "PERSON C"
        }
    ),
    CALCULATE(
        [average],
        'report'[NAME] IN {
            "PERSON A",
            "PERSON B"
        }
)

 

 

 

 

 


For some reason, I can't get to use log_date column, It does not prepolute in the new measure creation.
Not sure how to address this, Error: "A single value for variation 'DATE' for column [log_date] in table 'report' cannot be determined. This can happen when a mesaure formula refers to a column that contains many values (I do see null and blank in there)" Could use some hints/tips please

 

Thanks,

 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

You cant directly use log_date column inside "if", you need to add some extra dax function to use like max or selectedvalue e.g.

IF(
    Quater(Max(report[log_date]))= 4,
    CALCULATE(
        [average],
        'report'[NAME] IN {
            "PERSON A",
            "PERSON B",
            "PERSON C"
        }
    ),
    CALCULATE(
        [average],
        'report'[NAME] IN {
            "PERSON A",
            "PERSON B"
        }
)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

That's it! Thanks Samarth 😊

Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

You cant directly use log_date column inside "if", you need to add some extra dax function to use like max or selectedvalue e.g.

IF(
    Quater(Max(report[log_date]))= 4,
    CALCULATE(
        [average],
        'report'[NAME] IN {
            "PERSON A",
            "PERSON B",
            "PERSON C"
        }
    ),
    CALCULATE(
        [average],
        'report'[NAME] IN {
            "PERSON A",
            "PERSON B"
        }
)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors