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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.