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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
nok
Advocate II
Advocate II

Measure that uses quarter filter to compare year

Hi!

I have two tables that follow this structure:
Calendar

Year-Quarter  Year
2024 Q1        2024   
2024 Q2  2024
2024 Q3  2024
2024 Q4  2024
2025 Q1  2025
2025 Q2  2025
2025 Q3  2025
2025 Q4  2025

 

Sales

Year-Quarter  CreatedDate  Status
2024 Q101/02/2023Completed    
2024 Q219/04/2024Completed
2024 Q313/07/2024In progress
2024 Q422/12/2025Completed
2025 Q112/12/2024In progress
2025 Q230/11/2025Completed
2025 Q327/09/2025In progress
2025 Q423/04/2025Completed

 

In my dashboard, I have a "Year-Quarter" filter coming from the Calendar table. My two tables are related by the Year-Quarter column. I want to create a measure that counts rows in my Sales table where the Status is "Completed" and the CreatedDate has the same year as the user filter in the Year-Quarter filter.

Example 1: If the user filters 2025 Q-3, the measure should show the value 2 because of all the rows where the CreatedDate was in 2025 and the Year-Quarter is 2025 as well, there are two rows with "Completed" status.

Example 2: If the user filters 2024 Q-1, the measure should show the value 1 because of all the rows where the CreatedDate was in 2024 and the Year-Quarter is 2024 as well, there is only one rowswith "Completed" status.


How can I do that measure?

1 ACCEPTED SOLUTION
KarinSzilagyi
Super User
Super User

Hi @nok, did you mean a measure like this?

KarinSzilagyi_0-1759759381030.png

KarinSzilagyi_1-1759759434960.png

 

Completed same year as selection = 
VAR SelYear = SELECTEDVALUE ( DimDate[Year] )
RETURN
IF (
    ISBLANK ( SelYear ),
    BLANK (),
    CALCULATE (
        COUNTROWS ( FactSales ),
        FactSales[Status] = "Completed",
        FILTER (
            ALL ( FactSales[Year-Quarter] ),
            VALUE ( LEFT ( FactSales[Year-Quarter], 4 ) ) = SelYear
        ),
        FILTER (
            ALL ( FactSales[CreatedDate] ),
            YEAR ( FactSales[CreatedDate] ) = SelYear
        )
    )
)

a  



Did I answer your question? If so, please consider marking my response as the ‘Accepted Solution’ - it helps others with the same issue find the answer more easily!

View solution in original post

3 REPLIES 3
DataNinja777
Super User
Super User

Hi @nok ,

 

You can achieve this with a DAX measure that uses a combination of CALCULATE, FILTER, ALL, and SELECTEDVALUE. This approach allows the measure to correctly identify the year from the slicer and apply it as a filter condition across the entire Sales table, regardless of the specific quarter selected.

Completed Sales by Selected Year =
VAR SelectedYear =
    SELECTEDVALUE ( 'Calendar'[Year] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Sales' ),
        FILTER (
            ALL ( 'Sales' ),
            'Sales'[Status] = "Completed"
                && YEAR ( 'Sales'[CreatedDate] ) = SelectedYear
        )
    )

This measure first declares a variable, SelectedYear, which captures the single year value from your slicer's context using SELECTEDVALUE. For instance, if '2025 Q3' is selected, this variable holds the value 2025. The CALCULATE function then modifies the context for the COUNTROWS calculation. The key is the FILTER logic. By using ALL('Sales'), we tell the formula to remove the initial filter from the slicer (the specific quarter) and look at the entire Sales table. It then iterates through every row of this unfiltered table and applies new criteria: it keeps only the rows where the Status is "Completed" and where the year of the CreatedDate matches the SelectedYear variable. The final result is a count of all rows that meet these two conditions for the selected year.

 

Best regards,

Hi @DataNinja777, I like your solution, but with your Measure I get 3 completed if I select 2025 Q3 rather than 2 as in OPs example:

KarinSzilagyi_0-1759759878826.png

 



Did I answer your question? If so, please consider marking my response as the ‘Accepted Solution’ - it helps others with the same issue find the answer more easily!
KarinSzilagyi
Super User
Super User

Hi @nok, did you mean a measure like this?

KarinSzilagyi_0-1759759381030.png

KarinSzilagyi_1-1759759434960.png

 

Completed same year as selection = 
VAR SelYear = SELECTEDVALUE ( DimDate[Year] )
RETURN
IF (
    ISBLANK ( SelYear ),
    BLANK (),
    CALCULATE (
        COUNTROWS ( FactSales ),
        FactSales[Status] = "Completed",
        FILTER (
            ALL ( FactSales[Year-Quarter] ),
            VALUE ( LEFT ( FactSales[Year-Quarter], 4 ) ) = SelYear
        ),
        FILTER (
            ALL ( FactSales[CreatedDate] ),
            YEAR ( FactSales[CreatedDate] ) = SelYear
        )
    )
)

a  



Did I answer your question? If so, please consider marking my response as the ‘Accepted Solution’ - it helps others with the same issue find the answer more easily!

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.