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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
maverickf17
Helper I
Helper I

Field parameters date issue

Hi All,
I am using a Field parameter calendar date.
----------------------------------------------------

maverickf17_0-1757298275523.png

-----------------------------------------------------------------


I am trying to calculate the dynamic variance based on Date ffield paramters.
But I am getting the below  output

maverickf17_1-1757298511447.png
Instead of 

maverickf17_2-1757298566281.png
-------------------------------------------------------------------------
I would appreciate if someone can do the chnages in the Pbix file.
The link to the pbix file is 

https://www.dropbox.com/scl/fi/nrmsq1ewbz86b1wjejm8h/Field_Parameters_yoy.pbix?rlkey=piu2nre1zv4nexg... 

The Page name is Field parameters data yoy.

-------------------------------------------------------------------------
Thanks,
ARJUN 





 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @maverickf17 ,

 

Let me start by the easy part the question is the context of the switch measure the calculations inside the switch are done in order and if it is true then it's stops and returns that calculation.

 

In your case you have the first value to be check is the ISINSCOPE ( 'Calendar'[Date].[Year] ) since the year is part of your table the result will always fall back to this one so giving you previous year value:

 

MFelix_1-1757322371617.png

 

If you redo the order like this:

Prev Test = 
SWITCH (
    TRUE (), 
    ISINSCOPE ( 'Calendar'[Date].[Day] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, DAY )
        ),
    ISINSCOPE ( 'Calendar'[Date].[Month] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, MONTH )
        ),
    ISINSCOPE ( 'Calendar'[Date].[Quarter] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, QUARTER )
        ),
    ISINSCOPE ( 'Calendar'[Date].[Year] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, YEAR )
        )
   
)

Starting on the lowest  value day then you get the expected result:

MFelix_2-1757322479359.png

 

 

 

However  I would advise you to be carefull with the  auto date-time option since the best practice for the usage of time intelligence calculations is to turn off auto date-time and create a full calendar table in your model, and also mark as a date table.

 

If you have adjust your calendar table to the format below and then redo your parameter table and the calculation like the formula below you should get expected result:

MFelix_0-1757321830327.png

 

Date param_ = {
    ("Quarter", NAMEOF('Calendar'[Quarter]), 0),
    ("Month", NAMEOF('Calendar'[Month]), 1),
    ("Day", NAMEOF('Calendar'[Day]), 2)
}

Prev Test = 
SWITCH (
    TRUE (),
    ISINSCOPE ( 'Calendar'[Day] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, DAY )
        ),
    ISINSCOPE ( 'Calendar'[Month] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, MONTH )
        ),
    ISINSCOPE ( 'Calendar'[Quarter] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, QUARTER )
        ),
    ISINSCOPE ( 'Calendar'[Year] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, YEAR )
        )
  
)

 

Once again the order of the calculations is very important.

 

MFelix_3-1757322562503.png

 

You can always create you own date hierarchy using the right click on the column of the year and then 

MFelix_4-1757322618084.png

 

add the other columns also 

MFelix_5-1757322641817.pngMFelix_6-1757322672809.png

 

Check some links about this subject but there are a lot more

https://www.sqlbi.com/articles/automatic-time-intelligence-in-power-bi/

https://data-mozart.com/tiq-part-1-how-to-destroy-your-power-bi-model-with-auto-date-time/

https://www.sqlbi.com/articles/mark-as-date-table/

 

 

Please see file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

From your Matrix visual, just remove the Date Field and drag the Year field from the Calendar table.  Your measure will work fine.  You may also use visual calculations to get the previus row's value

Ashish_Mathur_0-1757474227472.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur , 

 

Thanks for your prompt response, I really appreciate it

 

Best Regards,

Lakshmi

v-lgarikapat
Community Support
Community Support

Hi @maverickf17 ,

Thanks for reaching out to the Microsoft fabric community forum.

@MFelix 

Thanks for your prompt response

 

@maverickf17 , 

I wanted to follow up and confirm whether you’ve had the opportunity to review the information  provided by @MFelix  If you have any questions or need further clarification, please don’t hesitate to reach out.

 

We truly appreciate your continued engagement and thank you for being an active and valued member of the community.

 

We look forward to hearing from you.

Best regards,
Lakshmi

MFelix
Super User
Super User

Hi @maverickf17 ,

 

Let me start by the easy part the question is the context of the switch measure the calculations inside the switch are done in order and if it is true then it's stops and returns that calculation.

 

In your case you have the first value to be check is the ISINSCOPE ( 'Calendar'[Date].[Year] ) since the year is part of your table the result will always fall back to this one so giving you previous year value:

 

MFelix_1-1757322371617.png

 

If you redo the order like this:

Prev Test = 
SWITCH (
    TRUE (), 
    ISINSCOPE ( 'Calendar'[Date].[Day] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, DAY )
        ),
    ISINSCOPE ( 'Calendar'[Date].[Month] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, MONTH )
        ),
    ISINSCOPE ( 'Calendar'[Date].[Quarter] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, QUARTER )
        ),
    ISINSCOPE ( 'Calendar'[Date].[Year] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, YEAR )
        )
   
)

Starting on the lowest  value day then you get the expected result:

MFelix_2-1757322479359.png

 

 

 

However  I would advise you to be carefull with the  auto date-time option since the best practice for the usage of time intelligence calculations is to turn off auto date-time and create a full calendar table in your model, and also mark as a date table.

 

If you have adjust your calendar table to the format below and then redo your parameter table and the calculation like the formula below you should get expected result:

MFelix_0-1757321830327.png

 

Date param_ = {
    ("Quarter", NAMEOF('Calendar'[Quarter]), 0),
    ("Month", NAMEOF('Calendar'[Month]), 1),
    ("Day", NAMEOF('Calendar'[Day]), 2)
}

Prev Test = 
SWITCH (
    TRUE (),
    ISINSCOPE ( 'Calendar'[Day] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, DAY )
        ),
    ISINSCOPE ( 'Calendar'[Month] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, MONTH )
        ),
    ISINSCOPE ( 'Calendar'[Quarter] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, QUARTER )
        ),
    ISINSCOPE ( 'Calendar'[Year] ),
        CALCULATE (
            [All Card Transactions],
            DATEADD ( VALUES ( 'Calendar'[Date] ), -1, YEAR )
        )
  
)

 

Once again the order of the calculations is very important.

 

MFelix_3-1757322562503.png

 

You can always create you own date hierarchy using the right click on the column of the year and then 

MFelix_4-1757322618084.png

 

add the other columns also 

MFelix_5-1757322641817.pngMFelix_6-1757322672809.png

 

Check some links about this subject but there are a lot more

https://www.sqlbi.com/articles/automatic-time-intelligence-in-power-bi/

https://data-mozart.com/tiq-part-1-how-to-destroy-your-power-bi-model-with-auto-date-time/

https://www.sqlbi.com/articles/mark-as-date-table/

 

 

Please see file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors