The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi all,
I want a matrix table showing the sales for the selected month and the same month last year.
I´ve created a formula that works fine:
apr-22 | |
Sales | 500 |
Sales (-1 Year) | 2 50 |
My goal is a table that looks like this instead.
apr-22 | apr-21 | |
Sales | 500 | 250 |
Cant figure it out, I think maybe a switch formula? But the problem is that I want the dates also to be visualised so the user now which period they are looking at.
Regards,
Niclas
Solved! Go to Solution.
Already replied - drop Year and Month on columns and the two measures to the values of a matrix visual
That table you posted would be good enough! How do I create it?
Already replied - drop Year and Month on columns and the two measures to the values of a matrix visual
Edit: Solved it, needed to the date to be in hierarchy. I guess if I want the same layout as a proper P&L I will need to build it through a P&L logic?
That display would be good enough! How do I create that table?
Drop Year and Month dimensions into the columns of a matrix and the two measures into the values section of a matrix visual
The way this is usually done is that you have 2 measures set up - base and SPLY (Same Period Last Year).
Base: SUM(SalesTable[SalesAmount])
SPLY: CALCULATE([Base], SAMEPERIODLASTYEAR(DimDate[Date]))
Then you just throw your both measures in the matrix while having the date dimension data on columns (for example).
This is great JirkaZ. Can you give me the same measure based on last year date but this time day of week aligned date instead of using calendar date alinged function of sameperiodlastyear? So when I choose 24 Apr 2025 in the row dimension of the matrix visual, it will show the measure based on 25 Apr 2024 data instead of 24 Apr 2024 data in the columns of the matrix. Measure name can be SPLY_dowaligned.
Many thanks in advance.
Thanks for you reply!
Isnt that what I already have? I can see the the revenue from the 2 measures but the Column only show April 2022, not April 2021.
But that is correct. You have the definition almost OK - it's just that in the SPLY calculation you should reference the base measure instead of defining the calculation for the base measure again.
The Date dimension column will always only show the current date and you should name the SPLY measure the way that it's understandable that it's SPLY (you have that already too) 🙂
I used the reference as base in the new measure! But I´m still stuck with the visual problem in the matrix.
apr-22 | |
Sales | 500 |
SPLY | 250 |
Instead of:
apr-22 | SPLY | |
Sales | 500 | 250 |
That is a correct behavior and there's no way around that
Okay, thanks for your time! But there must be some other way to build this, using some other technique?
AFAIK there's no other way. You can't make column header names dynamic.
This is an correct display of the measures in the table.