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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
kgollapinni
Frequent Visitor

Current Year Values are displaying but Prior Year Values are not displaying

Hi All, 

 

I require a line graph that shows the CY and PY values based on the FISCAL year slicer selected on the top. It is showing me only CY values but not the PY values. If I selected the prior year (2023), I can see the PY graph. I want to see the PY values even without 2023 year being selected. 

 

Digital ToGo Avg Ticket PY Chart =
VAR SELECTED_DATE = IF(MAX(DATE_DIM_Fiscal[CALENDAR_DATE])>=TODAY(),TODAY()-1,MAX(DATE_DIM_Fiscal[CALENDAR_DATE]))
VAR END_PERIOD_PY =
LOOKUPVALUE(
    DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY],
    DATE_DIM_Fiscal[CALENDAR_DATE],
    SELECTED_DATE
) -52
VAR START_PERIOD_PY = END_PERIOD_PY - 12
VAR NUMERATOR =
CALCULATE(
    SUMX(
        FILTER(
            FACTTABLE,
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) >= START_PERIOD_PY &&
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) <= END_PERIOD_PY
        ),
        FACTTABLE[NET_SALES]
    ),
    KEEPFILTERS(
        FILTER(
            FACTTABLE,
            RELATED(Order_Dim[ORDER_CHANNEL]) = "Digital" &&
            RELATED(Order_Dim[ORDER_OCCASION]) = "ToGo"
        )
    ),
    REMOVEFILTERS (
        DATE_DIM_Fiscal[FISCAL_YEAR],
        DATE_DIM_Fiscal[QUARTER_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[MONTH_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[FISCAL_WEEK_NUMBER_YEAR]
    )
)
VAR DENOMINATOR =
CALCULATE(
    SUMX(
        FILTER(
            FACTTABLE,
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) >= START_PERIOD &&
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) <= END_PERIOD
        ),
        FACTTABLE[Transaction_Count]
    ),
    KEEPFILTERS(
        FILTER(
            FACTTABLE,
            RELATED(Order_Dim[ORDER_CHANNEL]) = "Digital" &&
            RELATED(Order_Dim[ORDER_OCCASION]) = "ToGo"
        )
    ),
    REMOVEFILTERS (
        DATE_DIM_Fiscal[FISCAL_YEAR],
        DATE_DIM_Fiscal[QUARTER_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[MONTH_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[FISCAL_WEEK_NUMBER_YEAR]
    )
)
RETURN DIVIDE(NUMERATOR, DENOMINATOR)
 
Digital ToGo Avg Ticket CY Chart =
VAR SELECTED_DATE = IF(MAX(DATE_DIM_Fiscal[CALENDAR_DATE])>=TODAY(),TODAY()-1,MAX(DATE_DIM_Fiscal[CALENDAR_DATE]))
VAR END_PERIOD =
LOOKUPVALUE(
    DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY],
    DATE_DIM_Fiscal[CALENDAR_DATE],
    SELECTED_DATE
)
VAR START_PERIOD = END_PERIOD - 12
VAR NUMERATOR =
CALCULATE(
    SUMX(
        FILTER(
            FACTTABLE,
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) >= START_PERIOD &&
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) <= END_PERIOD
        ),
        FACTTABLE[NET_SALES]
    ),
    KEEPFILTERS(
        FILTER(
            FACTTABLE,
            RELATED(Order_Dim[ORDER_CHANNEL]) = "Digital" &&
            RELATED(Order_Dim[ORDER_OCCASION]) = "ToGo"
        )
    ),
    REMOVEFILTERS (
        DATE_DIM_Fiscal[FISCAL_YEAR],
        DATE_DIM_Fiscal[QUARTER_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[MONTH_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[FISCAL_WEEK_NUMBER_YEAR]
    )
)
VAR DENOMINATOR =
CALCULATE(
    SUMX(
        FILTER(
            FACTTABLE,
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) >= START_PERIOD &&
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) <= END_PERIOD
        ),
        FACTTABLE[Transaction_Count]
    ),
    KEEPFILTERS(
        FILTER(
            FACTTABLE,
            RELATED(Order_Dim[ORDER_CHANNEL]) = "Digital" &&
            RELATED(Order_Dim[ORDER_OCCASION]) = "ToGo"
        )
    ),
    REMOVEFILTERS (
        DATE_DIM_Fiscal[FISCAL_YEAR],
        DATE_DIM_Fiscal[QUARTER_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[MONTH_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[FISCAL_WEEK_NUMBER_YEAR]
    )
)
RETURN DIVIDE(NUMERATOR, DENOMINATOR)

kgollapinni_0-1730869843734.png
If I select 2023 also on the slicer, I get this but just by selecting 2024, I want the below graph to be displayed.
kgollapinni_1-1730869890125.png

 

DATE_DIM_Fiscal = DATE_DIM
DATE_DIM = DATE_DIM_View
With the fact table, they are joined to many relationships with the DATE_KEY.
Even, if I change it to the the Matrix, I cannot view the values. Something is wrong with the DAX. Can someone help me with the issue?

@Ashish_Mathur @lbendlin @rajendraongole1 @Ritaf1983 @amitchandak @Kedar_Pande 

1 ACCEPTED SOLUTION
kgollapinni
Frequent Visitor

I was debugging line-by-line and in the PY somehow the KEEPFILTERS was affected. I removed KEEPFILTERS and used it in FILTERS, which worked for me. 

View solution in original post

2 REPLIES 2
kgollapinni
Frequent Visitor

I was debugging line-by-line and in the PY somehow the KEEPFILTERS was affected. I removed KEEPFILTERS and used it in FILTERS, which worked for me. 

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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 MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.