The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello together,
I have the following problem: I have a matrix with grades as rows and dates (months-year) as columns. The value is the number of grades for the corresponding month. The table looks similar to the following:
Grade | Jan 2020 | Feb 2020 | Mar 2020 | Apr 2020 |
1 | 1 | 2 | 3 | 3 |
2 | 3 | 3 | 4 | 4 |
3 | 4 | 4 | 2 | 5 |
4 | 5 | 6 | 1 | 6 |
What I want to achieve is the following: If I select the columns Mar 2020 & Jan 2020, I want to see how the number of grades has changed, for example, for grade 1 I want to see the result of this calculation: 3-1=2, for grade 2 I want to see 4-3=1, etc.
Ideally, a new column would automatically occur after the column Mar 2020 and is labeled as "Difference" or something similar. Is something like that somehow possible?
Thank you in advance:)
@Anonymous , if this you raw format, Unpivot it, Get month in row. You can have date from the month and use time intelligence
date ="01-" & right([month],3) &"-" & left([month],4) //mark as date column
example - with date table
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
diff = [MTD Sales]-[last MTD Sales]
Thank you for your answer @amitchandak . I want this to be dynamic so that the user can select the specific columns where he wants to see the difference. Is your solution dynamic? I guess, in your solutions, I have to specify the specific columns beforehand.
Hi @Anonymous,
If you do unpivot columns on your date field to convert them as attribute and value, they will expand your records with different these date values.
Unpivot columns (Power Query)
If you use these fields to create a matrix and write a measure formula based on current row contents, it can be dynamic changes based on your selections.
Using the SELECTEDVALUE function in DAX
Regards,
Xiaoxin Sheng
@Anonymous Yes, I would have to dig up the various threads on this, there are multiple but it comes down to using ALL and then FILTER to filter down to the rows you want. Would need sample source data to be more specific. Sorry, having trouble following, can you post sample data as text and expected output. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
I'll try to dig up the threads.