Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi there,
I`m using measures to determine the difference between months (current en past year). The financial table uses a number for a month and I have a date table connected with it. I have a visual that shows the values but I dont want it to show the coming months. I`ve been trying to hide with a switch but then it only shows the current month. Any ideas what i`m doing wrong?
What I`m trying to achieve. A table that only shows the current and past months
Current month august, so sep-dec should be empty
MONTH Difference
1 10
2 30
3 40
4 -20
5 -50
6 80
7 10
8 12
9
10
11
12
My Code:
CheckMonthDiff =
VAR CurrentMonth = MONTH (TODAY ())
RETURN
Switch ( True(),
IF([CurrentMonth] <= 1,"",[JanMonthDiff]),
IF([CurrentMonth] <= 2,"",[FebMonthDiff]),
IF([CurrentMonth] <= 3,"",[MarMonthDiff])
...
...
IF([CurrentMonth] <= 12,"",[DecMonthDiff])
)
Solved! Go to Solution.
Hi @hilvie ,
Based on your description, I have created a simple sample like this:
Please try:
Diff =
VAR _currentyear =
YEAR ( TODAY () )
RETURN
IF (
MAX ( 'Calendar'[Month] ) <= MONTH ( TODAY () ),
SUMX (
FILTER (
'Table',
[Month] = MAX ( 'Calendar'[Month] )
&& YEAR ( [Date] ) = _currentyear
),
[Value]
)
- SUMX (
FILTER (
'Table',
[Month] = MAX ( 'Calendar'[Month] )
&& YEAR ( [Date] ) = _currentyear - 1
),
[Value]
)
)
Then select show items with no data:
Final Output:
If the result is not what you want, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.
Refer to:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @hilvie ,
Based on your description, I have created a simple sample like this:
Please try:
Diff =
VAR _currentyear =
YEAR ( TODAY () )
RETURN
IF (
MAX ( 'Calendar'[Month] ) <= MONTH ( TODAY () ),
SUMX (
FILTER (
'Table',
[Month] = MAX ( 'Calendar'[Month] )
&& YEAR ( [Date] ) = _currentyear
),
[Value]
)
- SUMX (
FILTER (
'Table',
[Month] = MAX ( 'Calendar'[Month] )
&& YEAR ( [Date] ) = _currentyear - 1
),
[Value]
)
)
Then select show items with no data:
Final Output:
If the result is not what you want, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.
Refer to:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for this!!!!
I`ve added a YEAR column and the visual works:
Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive.
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. Screenshots of the expected outcome are ok.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
107 | |
88 | |
76 | |
67 |
User | Count |
---|---|
126 | |
111 | |
100 | |
83 | |
71 |