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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
anabianco09
Helper II
Helper II

Creating a measure with an IF statement regarding dates

Hi there, 

I am wondering if it is possible to create a measure that will change values according to a DATE column?

For example, IF Date = 24/12/2023, Measure is 5, also if 01/01/2024, Measure is 4...

 

Thank you,

5 REPLIES 5
shoptinhyeuvn
New Member

I think so

Power5
Helper IV
Helper IV

Did you try and write an if statement? Can I see it?

I have an if statement to create a column, but I am wondering if I can create a measure with an IF statement:

 

= Table.AddColumn(#"Added Conditional Column4", "Capacity", each if [CalendarDate] = #date(2023, 12, 25) then 3 else if [CalendarDate] = #date(2023, 12, 26) then 3 else if [CalendarDate] = #date(2023, 12, 27) then 3 else if [CalendarDate] = #date(2023, 12, 28) then 3 else if [CalendarDate] = #date(2023, 12, 29) then 3 else if [CalendarDate] = #date(2023, 11, 13) then 5 else if [CalendarDate] = #date(2023, 11, 14) then 5 else if [CalendarDate] = #date(2023, 11, 15) then 5 else if [CalendarDate] = #date(2023, 11, 16) then 5 else if [CalendarDate] = #date(2023, 11, 17) then 5 else if [CalendarDate] = #date(2024, 1, 1) then 5 else if [CalendarDate] = #date(2024, 1, 2) then 5 else if [CalendarDate] = #date(2024, 1, 3) then 5 else if [CalendarDate] = #date(2024, 1, 4) then 5 else if [CalendarDate] = #date(2024, 1, 5) then 5 else if [CalendarDate] = #date(2024, 3, 25) then 5 else if [CalendarDate] = #date(2024, 3, 26) then 5 else if [CalendarDate] = #date(2024, 3, 27) then 5 else if [CalendarDate] = #date(2024, 3, 28) then 5 else if [CalendarDate] = #date(2024, 3, 29) then 5 else if [CalendarDate] = #date(2024, 5, 20) then 5 else if [CalendarDate] = #date(2024, 5, 21) then 5 else if [CalendarDate] = #date(2024, 5, 22) then 5 else if [CalendarDate] = #date(2024, 5, 23) then 5 else if [CalendarDate] = #date(2024, 5, 24) then 5 else if [CalendarDate] = #date(2024, 7, 1) then 5 else if [CalendarDate] = #date(2024, 7, 2) then 5 else if [CalendarDate] = #date(2024, 7, 3) then 5 else if [CalendarDate] = #date(2024, 7, 4) then 5 else if [CalendarDate] = #date(2024, 7, 5) then 5 else if [CalendarDate] = #date(2024, 8, 5) then 5 else if [CalendarDate] = #date(2024, 8, 6) then 5 else if [CalendarDate] = #date(2024, 8, 7) then 5 else if  [CalendarDate] = #date(2024, 9, 2) then 5 else if [CalendarDate] = #date(2024, 9, 3) then 5 else if [CalendarDate] = #date(2024, 9, 4) then 5 else if [CalendarDate] = #date(2024, 9, 5) then 5 else if [CalendarDate] = #date(2024, 9, 6) then 5 else 6)

anabianco09
Helper II
Helper II

Hi, what I am trying to do is display that measure in a chart (column) as a line (secondary axis). 

I don't have a sample data, but I want this measure to take a specific value if the date (which is displayed on the x-axis) is any holiday for example. 

This measure represents the capacity of a shop, so if the dates fall into a week with a holiday, this capacity drops down to 3, instead of the usual 6, for example.

Power5
Helper IV
Helper IV

Can you please supply sample data so I can mimic it.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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