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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
surajbh
Helper I
Helper I

Create a column with condition based on different columns

Hi all, 
I want to create a formula in DAX, which create a case/ condition as column - status (New, updated,unchanged).
that should compare between today vs yesterday (latest date as of yesterday) and primary key, sales )

 

surajbh_0-1634032285099.png

Let me know if the above question/query is still unclear. 
Thank you very much for the support. 

Greeting,

2 ACCEPTED SOLUTIONS

@amitchandak  thank you for the code.
if in the above scenario, if I want to find the delta of sales with reference today(the one which I filter) and yesterday (with reference to filtered)- what could you suggest to write in dax.
thank you in advance. 

View solution in original post

Hi @surajbh ,

The reference could be like this:

Reference = 
VAR _last =
    MAXX (
        FILTER (
            'Table',
            [Date]
                = EARLIER ( 'Table'[Date] ) - 1
                && [Primary key] = EARLIER ( 'Table'[Primary key] )
        ),
        [Sales]
    )
return
[Sales] - _last

vyingjl_0-1634264642698.png

 

Best Regards,
Community Support Team _ Yingjie Li
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
surajbh
Helper I
Helper I

@v-yingjl  thank you for the support. 
if in the above-given scenario, the user has the possibility of filtering or choosing ( two dates- one to another date ), that will determine the status of the primary key. 
How could you write DAX.
thank you in advance for the support.

amitchandak
Super User
Super User

@surajbh , Try a new column

 

new column =
var _last = maxx(filter(Table, [Date] =earlier([Date])-1 && [primary key] =earlier([primary key])),[sales])
return
Switch(true() ,
isblank(_last) , "New" ,
_last <> [sales] , "Updated"
,"same"
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  thank you for the code.
if in the above scenario, if I want to find the delta of sales with reference today(the one which I filter) and yesterday (with reference to filtered)- what could you suggest to write in dax.
thank you in advance. 

Hi @surajbh ,

The reference could be like this:

Reference = 
VAR _last =
    MAXX (
        FILTER (
            'Table',
            [Date]
                = EARLIER ( 'Table'[Date] ) - 1
                && [Primary key] = EARLIER ( 'Table'[Primary key] )
        ),
        [Sales]
    )
return
[Sales] - _last

vyingjl_0-1634264642698.png

 

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

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.