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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mariogonzra
New Member

Measure ALLSELECTED not being affected by columns

 Hi, everyone:

 

I'm starting in PowerBI and I have a simple doubt that may be easy to resolve, but cannot find anywhere.

I have the following Matrix or whichever visual and I would like to create a mesaure that returns the value for the category "all" to all the lines. However, I cannot seem to get it right. The measure I'm using is the following

 

age.patients.total = CALCULATE(SUM(Table[patients], FILTER(ALLSELECTED(Table),Table[Age] = "All"). But as you can see below, it will work taking into account the outside filters and the row context but not for the columns (it's adding up the values for the different quarters/columns). I know the ALLSELECTED functions makes the measure to ignore the query filters, but is there any way around this?

 

99c56670-1c79-404c-8269-3b96eb14785b.jpeg

 

Can anyone help?

 

Thanks,

 

Mario

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi,

@Ritaf1983 , thank for your concern about the problem, and i want to offer some more information for user to refer to.

hello @mariogonzra , based on your description, if your date column is based on a date table, you can try the following solution.

Sample data

vxinruzhumsft_0-1717384542183.png

Create a calendar table and create a one-many relationship between tables.

Calendar = CALENDAR(DATE(2024,1,1),DATE(2024,12,31))

vxinruzhumsft_1-1717384603385.png

Then create a measure

age.patients.total =
CALCULATE (
    SUM ( 'Table'[patients] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [Age] = "All"
            && YEAR ( [Date] ) = YEAR ( MAX ( 'Calendar'[Date] ) )
            && QUARTER ( [Date] ) = QUARTER ( MAX ( 'Calendar'[Date] ) )
    )
)

Put the following field to the matrix

vxinruzhumsft_2-1717384681706.png

 

Output

vxinruzhumsft_3-1717384710097.png

Best Regards!

Yolo Zhu

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-xinruzhu-msft
Community Support
Community Support

Hi,

@Ritaf1983 , thank for your concern about the problem, and i want to offer some more information for user to refer to.

hello @mariogonzra , based on your description, if your date column is based on a date table, you can try the following solution.

Sample data

vxinruzhumsft_0-1717384542183.png

Create a calendar table and create a one-many relationship between tables.

Calendar = CALENDAR(DATE(2024,1,1),DATE(2024,12,31))

vxinruzhumsft_1-1717384603385.png

Then create a measure

age.patients.total =
CALCULATE (
    SUM ( 'Table'[patients] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [Age] = "All"
            && YEAR ( [Date] ) = YEAR ( MAX ( 'Calendar'[Date] ) )
            && QUARTER ( [Date] ) = QUARTER ( MAX ( 'Calendar'[Date] ) )
    )
)

Put the following field to the matrix

vxinruzhumsft_2-1717384681706.png

 

Output

vxinruzhumsft_3-1717384710097.png

Best Regards!

Yolo Zhu

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

 

Ritaf1983
Super User
Super User

Hi @mariogonzra 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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