March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi, I have a Matrix visual where I have data for two years, but I want to show quarter data only for the current year and keep prior year as one column only. How do I go about this?
Thank you
Solved! Go to Solution.
Hi @Hermarian
Please try this:
First of all, I create a set of sample:
Then create a new table:
Table 2 = {"_Last year","1Q","2Q","3Q","4Q"}
Then add a measure:
MEASURE =
VAR _newValue =
SELECTEDVALUE ( 'Table 2'[Value] )
VAR _MaxYear =
YEAR ( MAX ( 'Table'[Date] ) )
VAR _currentQuarter =
QUARTER ( MAX ( 'Table'[Date] ) )
VAR _Sumvalue =
SWITCH (
_newValue,
"_Last year",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( ALLSELECTED ( 'Table' ), YEAR ( 'Table'[Date] ) = _MaxYear - 1 )
),
"1Q",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = _MaxYear
&& QUARTER ( 'Table'[Date] ) = 1
)
),
"2Q",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = _MaxYear
&& QUARTER ( 'Table'[Date] ) = 2
)
),
"3Q",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = _MaxYear
&& QUARTER ( 'Table'[Date] ) = 3
)
),
"4Q",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = _MaxYear
&& QUARTER ( 'Table'[Date] ) = 4
)
)
)
RETURN
_Sumvalue
The result is as follow:
If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
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
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Hermarian
Please try this:
First of all, I create a set of sample:
Then create a new table:
Table 2 = {"_Last year","1Q","2Q","3Q","4Q"}
Then add a measure:
MEASURE =
VAR _newValue =
SELECTEDVALUE ( 'Table 2'[Value] )
VAR _MaxYear =
YEAR ( MAX ( 'Table'[Date] ) )
VAR _currentQuarter =
QUARTER ( MAX ( 'Table'[Date] ) )
VAR _Sumvalue =
SWITCH (
_newValue,
"_Last year",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( ALLSELECTED ( 'Table' ), YEAR ( 'Table'[Date] ) = _MaxYear - 1 )
),
"1Q",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = _MaxYear
&& QUARTER ( 'Table'[Date] ) = 1
)
),
"2Q",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = _MaxYear
&& QUARTER ( 'Table'[Date] ) = 2
)
),
"3Q",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = _MaxYear
&& QUARTER ( 'Table'[Date] ) = 3
)
),
"4Q",
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = _MaxYear
&& QUARTER ( 'Table'[Date] ) = 4
)
)
)
RETURN
_Sumvalue
The result is as follow:
If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
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
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Hermarian , Create a new column in your table and use in visual
New Qtr =if( [Year] < year(Today()) , [Year], [Qtr])
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
115 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
167 | |
117 | |
63 | |
57 | |
50 |