Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Issues with FILTER and ALLSELECTED when using filters from dimension table

Hello all,

 

I have a very basic calculation that I want to do; I have a table that contains for every week, how many open work items there are and how they are split between teams, types and other criteria. Please find the sample data attached:

 

Date_IDTeam_IDTypeProject Total Count
2023_12_041Type 1Project 19
2023_12_041Type 2Project 18
2023_12_042Type 1Project 16
2023_12_042Type 2Project 17
2023_12_043Type 1Project 114
2023_12_043Type 2Project 115
2023_12_011Type 1Project 17
2023_12_011Type 2Project 16
2023_12_012Type 1Project 14
2023_12_012Type 2Project 15
2023_12_013Type 1Project 112
2023_12_013Type 2Project 113
2023_11_241Type 1Project 15
2023_11_241Type 2Project 14
2023_11_242Type 1Project 12
2023_11_242Type 2Project 13
2023_11_243Type 1Project 110
2023_11_243Type 2Project 111

 

Through a measure I want to find out, how many items there have been at the previous date. Getting the Date_ID of the previous date works easily via the following variable within my measure:

 

var Previousdate = MAXX(FILTER(ALLSELECTED(Items), Items[Date_ID]<SELECTEDVALUE(Items[Date_ID])), Items[Date_ID])
 

 

Returning the Count of Items for the previous week is tricky; I tried the following measure:

 

Total_Count_Previousdate = SUMX(Filter(Items, Items[Date_ID]=Previousdate),Items[Total Count])
 
which does not yield any results, therefore I tried:
 
Total_Count_Previousdate = SUMX(FIlter(ALLSELECTED(Items),Items[Date_ID]=Previousdate),Items[Total Count])
 
which delivers the numbers that I want to see:
 

 

However; I also want those numbers to react to filters, which is only possible when I use filter attributes from this table (e.g. TEAM_ID), not attributes from a related dimension table like this one:
 
TEAM_IDTEAM_NAME
1Team 1
2Team 2
3Team 3
 
 How can I adjust the measure so that the numbers will be influenced by filters that I set on another dimension table?
 
Any help is appreciated!
 
Thanks!!!
 
 
 

 

 
 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    Thanks for reaching out to us with your question. Base on my description, it seems that you want to filter the data correctly base on another dimension table. Did you create any relationship with team dimension table and Items table? If yes, it should filter the data correctly. Please find the details in the attachment.

    If the above one can't help you get the expected result, please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with specific examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

    How to provide sample data in the Power BI Forum

     

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards

2 Replies

  • CoreyP's avatar
    CoreyP
    Icon for Solution Sage rankSolution Sage

    I would also recommend changing the data type of your date ID column to date, and creating a date dimension table. Power BI has really awesome time intelligence DAX functions that only work if you have a date table in your star schema. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Thanks for reaching out to us with your question. Base on my description, it seems that you want to filter the data correctly base on another dimension table. Did you create any relationship with team dimension table and Items table? If yes, it should filter the data correctly. Please find the details in the attachment.

    If the above one can't help you get the expected result, please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with specific examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

    How to provide sample data in the Power BI Forum

     

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards