Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Good afternoon everyone,
I hope everyone is well and can maybe help me with a problem I am trying to solve.
I created a matrix visual with dates on the columns and index names on the rows. I wanted to show the evolution of the index's prices over the years so I created a measure to calculate the price based on the year. If it is a past year then it should be the average of real price, if current year the average of real + future price and if future year then just the average of the expected future prices. So far, so good and I ended with a table like this: (simplified for sharing purposes)
| 2021 | 2022 | 2023 | 2024 | 2025 | |
| Index A | 0.4 | 1.1 | 0.7 | 0.6 | 0.9 |
| Index B | 2.1 | 4.7 | 5.1 | 4.9 | 3.2 |
| Index C | 1.3 | 1.4 | 1.5 | 0.9 | 1.3 |
Then I thought it would be nice to add some icon conditional formatting as a visual aid to indicate if the price for each index increased or decreased compared to the previous year. This is where things started to get more complicated. Since all the values come from the same measure I couldnt easily compare them. I tried creating a new measure to compare each value with the one on the previous column and return a value from -1 to 1 to then apply the conditional formatting based on this measure, but I cannot seem to find a way to effectively call and compare the columns.
Here is the measure I tried to create:
Would really appreciate some help on this matter!
Many thanks in advance,
Miguel
Solved! Go to Solution.
Thanks for the reply from lbendlin, please allow me to provide another insight.
Hi @mikeminu ,
Please refers to the following steps.
Below is my testing data table.
Create a date table and establish a relationship with the source table.
DimDate = ADDCOLUMNS(
CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),
"Year", YEAR([Date])
)
Use the following measure to set the conditional format of the matrix values.
Measure =
VAR SelectedYear = SELECTEDVALUE(DimDate[Year])
VAR CurrentYearValue = CALCULATE([Sum of price], DimDate[Year]=SelectedYear)
VAR PreviousYearValue = CALCULATE([Sum of price], DimDate[Year]= SelectedYear-1)
RETURN
SWITCH(
TRUE(),
CurrentYearValue>PreviousYearValue,1,
CurrentYearValue<PreviousYearValue,-1,
0
)
The final result is as follows. Hopefully it will meet your needs.
Please see the attached pbix for reference.
Best Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the reply from lbendlin, please allow me to provide another insight.
Hi @mikeminu ,
Please refers to the following steps.
Below is my testing data table.
Create a date table and establish a relationship with the source table.
DimDate = ADDCOLUMNS(
CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),
"Year", YEAR([Date])
)
Use the following measure to set the conditional format of the matrix values.
Measure =
VAR SelectedYear = SELECTEDVALUE(DimDate[Year])
VAR CurrentYearValue = CALCULATE([Sum of price], DimDate[Year]=SelectedYear)
VAR PreviousYearValue = CALCULATE([Sum of price], DimDate[Year]= SelectedYear-1)
RETURN
SWITCH(
TRUE(),
CurrentYearValue>PreviousYearValue,1,
CurrentYearValue<PreviousYearValue,-1,
0
)
The final result is as follows. Hopefully it will meet your needs.
Please see the attached pbix for reference.
Best Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 11 | |
| 11 | |
| 9 | |
| 8 | |
| 8 |