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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
IndrachapaLA
Frequent Visitor

Compare the values of two different dates (single date column) in the same table for each category

Hi All,

 

I'm trying to return a Yes / No value in a card visual in order to trigger a notificatoin alert to team members based on below condition.
IF(lates coverage % < previous coverage % for at least one project, "yes", "No")

If this condition is true for at least one project, I need to alert the particular team.

I use weekly data.

I tried below dax and it didn't work.

 
Alert1 =
var _latestCoverageValue = CALCULATE(MAX('Table1'[Coverage Value]),'Table1'[Date]=MAX('Table1'[Date]))
var _previousCoverageValue = CALCULATE(MAX('Table1'[Coverage Value]),'Table1'[Date]=(MAX('Table1'[Date])-7))
var _result =
IF(
    SELECTEDVALUE('Table1'[projectName])&&(_latestCoverageValue<_previousCoverageValue),
    "Yes", "NO"
)
return
    _result
 
Can anyone help with this please.
thanks
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please try something like below.

 

Alert1 =
VAR _project =
    ADDCOLUMNS (
        DISTINCT ( 'Table1'[projectName] ),
        "@latest",
            CALCULATE (
                MAX ( 'Table1'[Coverage Value] ),
                'Table1'[Date] = MAX ( 'Table1'[Date] )
            ),
        "@previous",
            CALCULATE (
                MAX ( 'Table1'[Coverage Value] ),
                'Table1'[Date]
                    = ( MAX ( 'Table1'[Date] ) - 7 )
            )
    )
VAR _condition =
    COUNTROWS ( FILTER ( _project, [@latest] < [@previous] ) )
VAR _result =
    IF ( _condition >= 1, "Yes", "NO" )
RETURN
    _result

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please try something like below.

 

Alert1 =
VAR _project =
    ADDCOLUMNS (
        DISTINCT ( 'Table1'[projectName] ),
        "@latest",
            CALCULATE (
                MAX ( 'Table1'[Coverage Value] ),
                'Table1'[Date] = MAX ( 'Table1'[Date] )
            ),
        "@previous",
            CALCULATE (
                MAX ( 'Table1'[Coverage Value] ),
                'Table1'[Date]
                    = ( MAX ( 'Table1'[Date] ) - 7 )
            )
    )
VAR _condition =
    COUNTROWS ( FILTER ( _project, [@latest] < [@previous] ) )
VAR _result =
    IF ( _condition >= 1, "Yes", "NO" )
RETURN
    _result

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi, Thank you so much for the support.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Kudoed Authors