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 guys,
I am building a measure to show the year before the latest as default (when no filter is selected). So far I have done it with the latest year (2019).
Here are all the measures I built including latest year which is working properly:
Total imports Year before the latest=
var yes=
CALCULATE(
SUM('Import CIF 2016'[CIF US$]);
SAMEPERIODLASTYEAR('Calendario Chileno'[Fecha]))
var no=
CALCULATE(
SUM('Import CIF 2016'[CIF US$]);
FILTER('Calendario Chileno';[Año Anterior])
)
return
IF (
[IsAnySlicerSelected?];
yes;
no
)
[Año Anterior] Year before the latest =
MAX('Calendario Chileno'[Año])-1
Solved! Go to Solution.
Hi @reymalave ,
We can try to create a measure for last year:
Total Importaciones Año Anterior Defeto UA =
VAR LatestYear =
CALCULATE ( MAX ( 'Calendario Chileno'[Año] ))
RETURN
IF (
ISFILTERED('Calendario Chileno'[Año]),
SUM ( 'Import CIF 2016'[CIF US$] ),
CALCULATE (
SUM ( 'Import CIF 2016'[CIF US$] ),
FILTER ( 'Calendario Chileno','Calendario Chileno'[Año] = LatestYear - 1 )
)
)
Please delete the shared link if it contain any confidential information or comes from real data.
Best regards,
Hi @reymalave ,
We can try use following measure to meet your requirement if you want to show total number of the year before lastet year when no filtered applied:
Total imports latest year =
VAR IsAnyFilter =
IF (
CALCULATE ( COUNTROWS ( 'Import CIF 2016' ); ALL ( 'Import CIF 2016' ) )
- CALCULATE ( COUNTROWS ( 'Import CIF 2016' ) ) <> 0;
TRUE ();
FALSE ()
)
VAR LatestYear =
CALCULATE ( MAX ( 'Calendario Chileno'[Año] ); ALL ( 'Import CIF 2016' ) )
RETURN
IF (
IsAnyFilter;
SUM ( 'Import CIF 2016'[CIF US$] );
CALCULATE (
SUM ( 'Import CIF 2016'[CIF US$] );
FILTER ( 'Calendario Chileno'; 'Calendario Chileno'[Año] = LatestYear - 1 )
)
)
If it doesn't meet your requirement, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.
Best regards,
Hi @v-lid-msft:
Thanks for you reply. The proposed measure partially worked it shows last years up until I select something on the year filter. I tried working it around but I cant pin point the error. You can download the pbix file here.
The expexcted result is as follows. Show current and prior year data by default and show selected data when a filter is applied. For example, on the second page of the report "Importaciones" there are four visualizations, three cards and one filter. First card shows the total imports for the selected year, second card shows total income for the year before, third shows Year over Year and the cluster column chart shows a visual monthly comparisson of selected year a prior. The measure you provided works fine until i use the filter then it shows current year.
Thanks for your time,
Kindly
Reynaldo
Hi @reymalave ,
We can try to create a measure for last year:
Total Importaciones Año Anterior Defeto UA =
VAR LatestYear =
CALCULATE ( MAX ( 'Calendario Chileno'[Año] ))
RETURN
IF (
ISFILTERED('Calendario Chileno'[Año]),
SUM ( 'Import CIF 2016'[CIF US$] ),
CALCULATE (
SUM ( 'Import CIF 2016'[CIF US$] ),
FILTER ( 'Calendario Chileno','Calendario Chileno'[Año] = LatestYear - 1 )
)
)
Please delete the shared link if it contain any confidential information or comes from real data.
Best regards,
Not very clear, what is the issue you are facing
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
134 | |
91 | |
89 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
72 | |
68 |