Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
We have a report with a slicer Year ( multiple selected values possible )
Sample : rule if day ( today() ) <= 15 take month before to calcul or > 15 take all
if user selected only 2019 :
it is the 2th of april 2019 : i must calcul from 01/01/2019 to 31/03/2019
From april 16th : i must calcul from 01/01/2019 to 16/04/2019
if user selected only 2018 : i take all 2018
if user take 2018 and 2017 : i take all 2017 and 2018
if user selected 2018 and 2019 :
i begin with this measure , does not work in all cases :
thanks for your helps.
Solved! Go to Solution.
Hi @Cobra77 ,
We can create calculated column in Calendar table firstly.
YearMonth = YEAR('Calendar'[Date])*100 + MONTH('Calendar'[Date])
Then create a measure as below.
Measure = VAR ym = YEAR ( TODAY () ) * 100 + MONTH ( TODAY () ) VAR a = DIVIDE ( [Total Accident] * 1000000, [Total wh] ) RETURN IF ( MAX ( 'Calendar'[Annee] ) = 2019 && DAY ( TODAY () ) <= 15, CALCULATE ( a, FILTER ( ALLSELECTED ( 'Calendar' ), 'Calendar'[YearMonth] < ym ) ), IF ( MAX ( 'Calendar'[Annee] ) = 2019 && DAY ( TODAY () ) > 15, CALCULATE ( a, FILTER ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] <= TODAY () ) ), IF ( MAX ( 'Calendar'[Annee] ) <> 2019, CALCULATE ( a, ALLSELECTED ( 'Calendar' ) ) ) ) )
Hi @Cobra77 ,
We can create calculated column in Calendar table firstly.
YearMonth = YEAR('Calendar'[Date])*100 + MONTH('Calendar'[Date])
Then create a measure as below.
Measure = VAR ym = YEAR ( TODAY () ) * 100 + MONTH ( TODAY () ) VAR a = DIVIDE ( [Total Accident] * 1000000, [Total wh] ) RETURN IF ( MAX ( 'Calendar'[Annee] ) = 2019 && DAY ( TODAY () ) <= 15, CALCULATE ( a, FILTER ( ALLSELECTED ( 'Calendar' ), 'Calendar'[YearMonth] < ym ) ), IF ( MAX ( 'Calendar'[Annee] ) = 2019 && DAY ( TODAY () ) > 15, CALCULATE ( a, FILTER ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] <= TODAY () ) ), IF ( MAX ( 'Calendar'[Annee] ) <> 2019, CALCULATE ( a, ALLSELECTED ( 'Calendar' ) ) ) ) )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |