Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
hi
i have a filter with 5 months values, lets say i have chosen 01.2022 and 03.2022.
i have an income column that contains income value for all dates within each month.
The problem:
i need to sum up income for all days in 01.2022 and 03.2022 and calculate the difference between the two months, i.e. income for max month - income for min month.
this should work with whatever 2 months i choose in the filter.
i have googled and couldn't find any solutions to this problem.
is this even possible?
Solved! Go to Solution.
H9 @Anonymous
Please try
Difference =
VAR SelectedMonths =
ALLSELECTED ( TableName[Month] )
VAR MaxMonth =
MAXX ( SelectedMonths, TableName[Month] )
VAR MinMonth =
MINX ( SelectedMonths, TableName[Month] )
VAR MaxValue =
CALCULATE ( [Income], TableName[Month] = MaxMonth )
VAR MinValue =
CALCULATE ( [Income], TableName[Month] = MinMonth )
RETURN
MaxValue - MinValue
the reason why i have to use index for this is that i have missing months in between, so the previousmonth etc functions won't work
@Anonymous
Yes, but what does that have to do with finding the two selected months? Gaps are irrelevant here.
that didn't work either 😞
what i have done so far which gets me a little on the way is the following:
Hi @Anonymous
It depend on the filter context of the visual itself. I can see that all columns are from the same table. Not having dimention tables might be little tricky. The solution I have provided earlier (if the month column is a numeric value column) should work, however, depending on the existing filter context, the filter of some columns might have to be removed. Please provide more context in order to support you further. Thank you.
@Anonymous
You can use Variables in the DAX Measures.
Helping Link: https://docs.microsoft.com/en-us/dax/best-practices/dax-variables
As communicated by @tamerj1 , you can cater this scenario.
Did I answer your question? Mark my post as a solution! Kudos are also appreciated!
H9 @Anonymous
Please try
Difference =
VAR SelectedMonths =
ALLSELECTED ( TableName[Month] )
VAR MaxMonth =
MAXX ( SelectedMonths, TableName[Month] )
VAR MinMonth =
MINX ( SelectedMonths, TableName[Month] )
VAR MaxValue =
CALCULATE ( [Income], TableName[Month] = MaxMonth )
VAR MinValue =
CALCULATE ( [Income], TableName[Month] = MinMonth )
RETURN
MaxValue - MinValue
i can't see how that will solve my problem.
i have a table visual with month and total_income and difference.
it should look like the following:
my problem is how to calculate the difference part, based on ANY chosen months in the filter.
Hi @Anonymous
For this you can use the Date Filter to set Max Min Range of Dates. Follow the instructions from the link:
https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range
Did I answer your question? Mark my post as a solution! Kudos are also appreciated!
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
25 | |
19 | |
18 | |
18 | |
15 |
User | Count |
---|---|
38 | |
22 | |
18 | |
15 | |
11 |