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! Request now

Reply
assemomar
Frequent Visitor

Add if statement to VAR

 

Kindly, if you could help me add an if statement in below VAR, 

If the statement is like this: if (AssetMaintenanceRequests[Month]) = "JAN," then VAR (as below)

Regard,,

 

VolumeJAN =
var Color = AssetMaintenanceRequests[Month]
var CarModel = CALCULATE(MAX('VOLUME-JAN'[volume]),AssetMaintenanceRequests[Month]= Color)
return CarModel
 
 
 
 

 

 

2 ACCEPTED SOLUTIONS
_AAndrade
Super User
Super User

Hi @assemomar,

Please try if this solve your problem:

VolumeJAN =
var Color = SELECTEDVALUE(AssetMaintenanceRequests[Month])
var CarModel = CALCULATE(MAX('VOLUME-JAN'[volume]),AssetMaintenanceRequests[Month]= Color)
return 
IF(Color = "JAN,"
CarModel )




Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

Anonymous
Not applicable

Hi @assemomar ,

Your solution is great, @_AAndrade . It worked like a charm! Here I have another idea in mind, and I would like to share it for reference.

I think we can use the IF function to check if the Color variable (which holds the month from AssetMaintenanceRequests[Month]) equals "JAN". If it does, we proceed with your original calculation to determine CarModel. If not, the function returns BLANK(), meaning no value will be returned for months other than January.

Here is the DAX I will provide.

VolumeJAN =
VAR Color = AssetMaintenanceRequests[Month]
RETURN
    IF (
        Color = "JAN",
        VAR CarModel =
            CALCULATE (
                MAX ( 'VOLUME-JAN'[volume] ),
                AssetMaintenanceRequests[Month] = Color
            )
        RETURN
            CarModel,
        BLANK ()
    )

 

 

 

Best Regards

Yilong Zhou

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

2 REPLIES 2
Anonymous
Not applicable

Hi @assemomar ,

Your solution is great, @_AAndrade . It worked like a charm! Here I have another idea in mind, and I would like to share it for reference.

I think we can use the IF function to check if the Color variable (which holds the month from AssetMaintenanceRequests[Month]) equals "JAN". If it does, we proceed with your original calculation to determine CarModel. If not, the function returns BLANK(), meaning no value will be returned for months other than January.

Here is the DAX I will provide.

VolumeJAN =
VAR Color = AssetMaintenanceRequests[Month]
RETURN
    IF (
        Color = "JAN",
        VAR CarModel =
            CALCULATE (
                MAX ( 'VOLUME-JAN'[volume] ),
                AssetMaintenanceRequests[Month] = Color
            )
        RETURN
            CarModel,
        BLANK ()
    )

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

_AAndrade
Super User
Super User

Hi @assemomar,

Please try if this solve your problem:

VolumeJAN =
var Color = SELECTEDVALUE(AssetMaintenanceRequests[Month])
var CarModel = CALCULATE(MAX('VOLUME-JAN'[volume]),AssetMaintenanceRequests[Month]= Color)
return 
IF(Color = "JAN,"
CarModel )




Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




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.

Top Solution Authors