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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
V0strox337
New Member

Card filtering from matrix

Hi there,

 

I have a matrix which shows monthly cost, YTD cost, last year YTD cost, YTD budget etc. The cost data is pulled from the transactions table & budget info from the budget table. I have a filter set up on the matrix for "in the last 1 calendar month" as i want to report on the previous month. I then have cards above the matrix with one being the full year budget. 

 

The issue i have here is when i click a certain cost category on the matrix (e.g. wages) i want the full year budget card to filter on this category but not on the last calendar month but can't work out how to do this. At present when i click on the matrix the fy budget card changes to the last calendar months value for the specific category i select. So essentailly i want the FY budget card to stay filtered on period 12 (as the budget table values are running balances each month) but want it filtered by the matrix category i select.

 

Is there an easy way of doing this?

 

Thanks   

2 REPLIES 2
123abc
Community Champion
Community Champion

 

To achieve the desired behavior of having a card display the full-year (FY) budget for a specific category while keeping the period fixed at 12 (for the full year), you can use a combination of measures and filter context manipulation in Power BI. Here's a step-by-step approach to do this:

 

1. Create a Measure for FY Budget:
- Create a measure that calculates the FY budget for the selected category. This measure should filter the budget data based on the selected category and period 12 (full year). For example:

 

DAX Measure
FY Budget = CALCULATE(SUM(BudgetTable[Budget]), BudgetTable[Category] = SELECTEDVALUE(Matrix[Category]), BudgetTable[Period] = 12)

2. Create a Measure for Last Month Cost:
- You mentioned that you have a filter for "in the last 1 calendar month." To calculate the cost for the last calendar month, create a measure that considers this filter. For example:

 

Dax Measure
Last Month Cost = CALCULATE(SUM(TransactionTable[Cost]), FILTER(TransactionTable, DateTable[InLastMonth] = TRUE()))

In this measure, `DateTable[InLastMonth]` is a placeholder for the logic that identifies whether a transaction is in the last calendar month.

 

3. Create a Measure for Selected Category Cost:
- Create a measure to calculate the cost for the selected category. This measure should consider the filter context set by the matrix visual. For example:

 

DAX Measure
Selected Category Cost = CALCULATE(SUM(TransactionTable[Cost]), FILTER(TransactionTable, TransactionTable[Category] = SELECTEDVALUE(Matrix[Category])))

4. Configure the Card Visual for FY Budget:
- In your card visual for FY budget, use the "FY Budget" measure you created in step 1. This card should always show the FY budget for the selected category, regardless of the matrix filter.

 

5. Configure the Matrix Visual:
- Make sure your matrix visual is using the "Last 1 Calendar Month" filter for its data. This filter will control the data displayed in the matrix.

 

6. Testing:
- Test your report by selecting different categories in the matrix. The FY budget card should remain fixed at the full-year budget for the selected category, and the matrix should update based on the selected category and the last calendar month.

 

By creating specific measures for FY budget, last month cost, and selected category cost, you can control the filter context for each visual independently, achieving the desired behavior in your report.

Sahir_Maharaj
Super User
Super User

Hello @V0strox337,

 

1. Create a DAX Measure for FY Budget by Category

FY Budget by Category = 
CALCULATE(
    SUM(BudgetTable[BudgetAmount]),
    FILTER(BudgetTable, BudgetTable[Category] = SELECTEDVALUE(Matrix[Category])),
    FILTER(BudgetTable, BudgetTable[Period] = 12)  // Assuming 12 is the fiscal year end
)

2. Create a DAX Measure for Last Calendar Month

Last Calendar Month Cost = 
CALCULATE(
    SUM(TransactionsTable[Cost]),
    FILTER(TransactionsTable, TransactionsTable[Date] >= STARTOFMONTH(TODAY()) - 1 && TransactionsTable[Date] <= ENDOFMONTH(TODAY()) - 1)
)

3. Create a Card Visualization for FY Budget: This card should display the budget for the selected category while the period remains fixed at 12

4. Create a Card Visualization for Last Calendar Month

 

Should you require further details or information, please do not hesitate to reach out to me.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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