Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Measure that uses time from the slicer for its calculations

Hello,

 

I posted this in Desktop but figured this might be a better place.

 

I want to try out a new ratio for my area (Number of A x Months of the period/...) and, while I have the logic for the formula, I don't know how to get the time frame selected in the slicer. My idea is that the time would be selected here:

 

An_Cll_PBI_1-1602207320119.png

 

The number of months in the time range selected would go into the measure, this is a ratio that's getting a color depending on the ratio value, but it has to be adjusted to the time frame.

 

Any ideas on how to get it done or what is my best option?

 

TIA

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , You can have measure like this give diff between dates

 

Measure =
var _min = minx(Allselected(Date), Date[Date])
var _max = maxx(Allselected(Date), Date[Date])
return
datediff(_min, _max , Month())

 

 

For conditional formatting, you can color measure like the example. Use this "Field value" option

 

Color sales = if(AVERAGE(Sales[Sales Amount])<170,"green","red")
Color Year = if(FIRSTNONBLANK('Table'[Year],2014) <=2016,"lightgreen",if(FIRSTNONBLANK('Table'[Year],2014)>2018,"red","yellow"))

color =
switch ( true(),
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity1" && sum('Table'[Value]) >500,"lightgreen",
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity2" && sum('Table'[Value]) >1000,"lightgreen",
// Add more conditions
"red"
)

 

 

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors