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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
yellow_old_5
Helper II
Helper II

show blank when calculate previous fiscal year

Hi All, I have a calendarweek table where they a fiscal year column , have a fiscal year filter and the user should see the selected year and previous fiscal year sales in a table, got blank when it shows previous years sales, my measure:

Previous Fiscal sales =
VAR currentFYYear = SELECTEDVALUE ( DimCalendarWeek[Fiscal Year Number])
VAR _PreviousFiscalYear = currentFYYear-1
return
CALCULATE (
        [sales],
        FILTER(DimCalendarYearWeek,
            DimCalendarYearWeek[Fiscal Year ] = _PreviousFiscalYear)
            ,FILTER(DimCategory, DimCategory[Sales Status] = "new")
    )
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @yellow_old_5 ,

 

The solution is to create a separate table with the field [Fiscal Year Number]. The Fiscal Year Number field of the new table is then filtered as a slicer field. Below is the solution steps based on simple sample data.

For example, if I select 2022, it should display data for 2021.

vstephenmsft_1-1694412028693.png

 

1.Create a separate table.

Table = DISTINCT('DimCalendarWeek'[Fiscal Year Number])

vstephenmsft_2-1694412038041.png

2.Create a slicer, the field is from the new separate table.

vstephenmsft_3-1694412110573.png

3.Create a measure. The fields in SELECTEDVALUE() function need to be modified to the fields of the new table. Nothing else needs to be changed, but I don't have a DimCategory table in the example, so I changed it.

Previous Fiscal sales = 
VAR currentFYYear = SELECTEDVALUE ('Table'[Fiscal Year Number])
VAR _PreviousFiscalYear = currentFYYear-1
return
CALCULATE (
       SUM(DimCalendarWeek[Sale]),
        FILTER('DimCalendarWeek',
            'DimCalendarWeek'[Fiscal Year Number] = _PreviousFiscalYear)
          
    )

vstephenmsft_4-1694412413484.png

Best Regards,

Stephen Tao

 

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
v-stephen-msft
Community Support
Community Support

Hi @yellow_old_5 ,

 

The solution is to create a separate table with the field [Fiscal Year Number]. The Fiscal Year Number field of the new table is then filtered as a slicer field. Below is the solution steps based on simple sample data.

For example, if I select 2022, it should display data for 2021.

vstephenmsft_1-1694412028693.png

 

1.Create a separate table.

Table = DISTINCT('DimCalendarWeek'[Fiscal Year Number])

vstephenmsft_2-1694412038041.png

2.Create a slicer, the field is from the new separate table.

vstephenmsft_3-1694412110573.png

3.Create a measure. The fields in SELECTEDVALUE() function need to be modified to the fields of the new table. Nothing else needs to be changed, but I don't have a DimCategory table in the example, so I changed it.

Previous Fiscal sales = 
VAR currentFYYear = SELECTEDVALUE ('Table'[Fiscal Year Number])
VAR _PreviousFiscalYear = currentFYYear-1
return
CALCULATE (
       SUM(DimCalendarWeek[Sale]),
        FILTER('DimCalendarWeek',
            'DimCalendarWeek'[Fiscal Year Number] = _PreviousFiscalYear)
          
    )

vstephenmsft_4-1694412413484.png

Best Regards,

Stephen Tao

 

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

Thanks , that works fine. I have another issue, now i want to use the same filter (fiscal year) but i want display year month that belongs to that fiscal year, how should i do?

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.