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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
jinivthakkar
Frequent Visitor

Show dax measure only for Jan to Jun

Hi All,

 

I have a dax which is looks something like this and it is working fine

MyMeasure1 = CALCULATE(
    [Table],
    ref_Dates[Date] >= DATE(2022,1,1),
    ref_Dates[Date] <= DATE(2022,6,30)
)
MyMeasure2 = CALCULATE(
    [Table1],
    ref_Dates[Date] >= DATE(2022,1,1),
    ref_Dates[Date] <= DATE(2022,6,30)
)

MyMeasure3 = MyMeasure1/MyMeasure2

I then use measure 1 and 2 in measure 3 and measure 3 is referred on the visuals and it shows a constant line from Jan to Dec which is as expected and correct but what I want to do is, show measure 3 value only from Jan to Jun and then 0 from Jul to Dec.

 

I tried adding If condition in measure 3 but it is giving me error.

 

Please guide/help.

 

TIA

1 ACCEPTED SOLUTION

Hey there @jinivthakkar ! In that case you can go with this:

MyMeasure3 =
SWITCH (
    TRUE (),
    MONTH ( MAX( ref_Dates[Date] ) ) >= 1
        && MONTH ( MAX( ref_Dates[Date] ) ) <= 6, DIVIDE( MyMeasure1 , MyMeasure2, 0 ),
    0
)

 

For additional help, please @ me in your reply!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

View solution in original post

6 REPLIES 6
jinivthakkar
Frequent Visitor

@goncalogeraldes thanks for your reply but I am getting error Cannot find name '[Date]':

 

jinivthakkar_0-1671110633475.png

I also tried a few other ways but nothing seems to work, basically my tables are not populating in the measure.

 

TIA

Hello there @jinivthakkar ! Try the following:

MyMeasure3 =
SWITCH (
    TRUE (),
    MONTH ( SELECTEDVALUE( ref_Dates[Date] ) ) >= 1
        && MONTH ( SELECTEDVALUE( ref_Dates[Date] ) ) <= 6, DIVIDE( MyMeasure1 , MyMeasure2 ),
    0
)

 

For additional help, please @ me in your reply!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

@goncalogeraldes I tried  this but this gives me a flat line or value as 0, I am not sure if SELECTEDVALUE will work, end users dont have option to select month value.

 

I already have a bar and line chart and just need to show existing measure only from Jan to Jun without user interaction.

Hey there @jinivthakkar ! In that case you can go with this:

MyMeasure3 =
SWITCH (
    TRUE (),
    MONTH ( MAX( ref_Dates[Date] ) ) >= 1
        && MONTH ( MAX( ref_Dates[Date] ) ) <= 6, DIVIDE( MyMeasure1 , MyMeasure2, 0 ),
    0
)

 

For additional help, please @ me in your reply!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

@goncalogeraldes Thanks buddy, cheers !!

goncalogeraldes
Super User
Super User

Hi @jinivthakkar ! You can try the following:

MyMeasure3 =
SWITCH (
    TRUE (),
    MONTH ( ref_Dates[Date] ) >= 1
        && MONTH ( ref_Dates[Date] ) <= 6, MyMeasure1 / MyMeasure2,
    0
)

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.