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

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.

Reply
Anonymous
Not applicable

Measures with Date Tables

Hi,

 

I am very new to Power BI and I am having trouble using a measure with a date table.

 

I created a date table for looking up

Dates = CALENDAR(TODAY()-1000,TODAY()+1000)

 

within which I made a column called MonthYear

MonthYear = 'Dates'[MonthShortName]&" "&'Dates'[Year]

 

When I create charts from my 'Fact Sheet' (Table1) it works fine and groups the data in MonthYear as I want it to do.

 

However, when I make a chart that has this measure in it

(

SLA % = 1-
DIVIDE (
SUM ( Table1[Incident Breached] ),
SUM ( Table1[Count])
)
 
It calculates the SLA % correctly for the months within my 'Fact Sheet' (Table1) but also tries to calculate SLA % for every month in the 'Date table' where there are no corresponding months in my 'Fact Sheet' (Table1).
 
Screen Shot 04-09-19 at 02.59 PM.PNG
 
I hope this makes sense.
 
Any help would be much appreciated.
 
Thanks,
Martin
1 ACCEPTED SOLUTION

@Anonymous sorry missed a bracket

 

SLA % = 
VAR d = 
DIVIDE (
  SUM ( Table1[Incident Breached] ),
  SUM ( Table1[Count])
)
RETURN
IF (ISBLANK(d), BLANK(),1-d)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

10 REPLIES 10
mussaenda
Super User
Super User

@parry2k's answer is way better!

Anonymous
Not applicable

Thanks for your help @mussaenda  🙂

@Anonymous sorry missed a bracket

 

SLA % = 
VAR d = 
DIVIDE (
  SUM ( Table1[Incident Breached] ),
  SUM ( Table1[Count])
)
RETURN
IF (ISBLANK(d), BLANK(),1-d)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

It works perfectly @parry2k 

 

Thanks very much for the help.  Much appreciated! 🙂

parry2k
Super User
Super User

@Anonymous did you setup relationship between your date and transaction table?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Wow, that was quick 🙂  Thanks for getting back to me @parry2k 

 

Yes, I think(?) I have

Screen Shot 04-09-19 at 03.08 PM.PNG

Here you can see two charts, both are using the same MonthYear axis 

But the one in the left (which does not use a measure) seems to work fine.

Screen Shot 04-09-19 at 03.11 PM.PNG

try setting your relationship direction to both

@Anonymous problem is your measure is returning 1 when there is no value in divided by and that's why you are seeing all the dates. I wouldn't recomment to set the relationship to both direction since it can have performances issue on large dataset.

 

try following

 

SLA % = 
VAR d = DIVIDE (
SUM ( Table1[Incident Breached] ),
SUM ( Table1[Count])
RETURN
IF (ISBLANK(d), BLANK(),1-d)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hey @parry2k ,

 

I tried what you said but got the following error message:

 

The syntax for 'RETURN' is incorrect. (DAX(VAR d = DIVIDE (SUM ( Table1[Incident Breached] ),SUM ( Table1[Count])RETURNIF (ISBLANK(d), BLANK(),1-d))).

Anonymous
Not applicable

Thanks @mussaenda

 

I changed the direction to 'both' but it still doesn't work ??

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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