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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Matt0515
Frequent Visitor

Measure on Date and Field Values

Hello, I am somewhat new to Power BI so any help is very much appreciated.

 

I have a dataset with a Product column and a Created Date coulmn

 

example would be:  Product Column = X, Created Date Column = 1/1/2019

 

I would like to create a measure that will count the number of records that = Product X and Date = Q1 2019

 

I assume I can plug in different values for different products/dates but I cannot figure out the DAX for the measure.

 

Thank you!

 

Matt

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Matt0515,

Do you mean to calculate with specific dare range and produce records count or dynamic calculate based on current product and date? If you mean static conditions, you can try to use the following measure formula:

Measure =
CALCULATE (
    COUNTROWS ( Table ),
    FILTER (
        ALLSELECTED ( Table ),
        Table[Product] = "X"
            && YEAR ( Table[Date] ) = 2019
            && QUARTER ( Table[Date] ) = 1
    )
)

For the dynamic version, you need to extract current date and product for calculating:

Measure =
VAR currDate =
    MAX ( Table[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( Table ),
        FILTER (
            ALLSELECTED ( Table ),
            Table[Product] IN VALUES ( Table[Product] )
                && YEAR ( Table[Date] ) = YEAR ( currDate )
                && QUARTER ( Table[Date] ) = QUARTER ( currDate )
        )
    )

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

HI @Matt0515,

Do you mean to calculate with specific dare range and produce records count or dynamic calculate based on current product and date? If you mean static conditions, you can try to use the following measure formula:

Measure =
CALCULATE (
    COUNTROWS ( Table ),
    FILTER (
        ALLSELECTED ( Table ),
        Table[Product] = "X"
            && YEAR ( Table[Date] ) = 2019
            && QUARTER ( Table[Date] ) = 1
    )
)

For the dynamic version, you need to extract current date and product for calculating:

Measure =
VAR currDate =
    MAX ( Table[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( Table ),
        FILTER (
            ALLSELECTED ( Table ),
            Table[Product] IN VALUES ( Table[Product] )
                && YEAR ( Table[Date] ) = YEAR ( currDate )
                && QUARTER ( Table[Date] ) = QUARTER ( currDate )
        )
    )

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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