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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
slava_aptown
Frequent Visitor

Set right filter context inside the SUMMARIZE expression

Hi!

I am struggling with keeping and removing certain filter contexts inside a DAX expression.

 

I have a table on monthly granularity. Daily value column is calculated as Monthly value divided by the number of days in a month.

Despite other data is on daily granularity, I do not want to move it to daily as it will be 200 mln rows.

MonthStoreProductValueDaily Value 
(Value / number of days in the month)
January 2024XX9393/31=3


The table has relationship with Calendar table as many-1 (Month column is formatted as the date 01.01.2024)

slava_aptown_0-1707756418333.png

 

I write a measure that calculates Value on daily granularity as 

 

 

Daily Value * number of days chosen in the month

 

 


This is the measure. I struggle at days_chosen. In this column I want to get virtual number of days chosen in the month.
If I do not have any outside filters it should be 31 for January. If I choose only January, 1-10 it should be 10.
I have tried many combinations of ALL, ALLSELECTED, KEEPFILTER etc, but I get either virtual 1 or 31 and it does not respond to my choice in slicer. 

 

 

VAR _tbl1 =
SUMMARIZE(
    table,
    'Calendar'[Month],
    table[store],
    table[product],
    "max_value", MAX(table[value]),
    "days_chosen", 
        COUNTROWS(
            CALCULATETABLE(
                'Calendar',
                'Calendar'[Month] = SELECTEDVALUE('Calendar'[Month]),
                KEEPFILTERS('Calendar'[Day])
            )
        )
)
RETURN
SUMX(
    _tbl1,
    [days_chosen] * [max_value]
)

 

 

 

1 REPLY 1
lbendlin
Super User
Super User

You may want to read this article

 

All the secrets of SUMMARIZE - SQLBI

 

Side question :  What is the number of days in "February"  ?  Which year?

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (25)