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
MauroBote
Helper I
Helper I

Relating date Slicer with a Calendar Date Line Chart

Hi friends.

 

I have a Calendar Table (CALENDARIO) created with the min and max of 2 columns dates ([Plan Date] and [Real Date]) from another table (HITOS), and I use it for the X axis of a Line Chart. Also I have a date Slicer (between) created with the column [Plan Date] from the same table used before (HITOS).

 

On the model, I have determined 2 diferent relationship between the 2 tables:

  • HITOS[Plan Date] with CALENDARIO[Date]
  • HITOS[Real Date] with CALENDARIO[Date]

Both relationships are inactives.

 

So, I need a way to change the X axis of the Line Chart with the dates selected on the Slicer.

 

Now I have this result:

As Is.png

 

And I need this one (I have change the date filter manually):

To Be.png

 

The model:

Model.png

 

Can anyone help me please?

 

Thanks!

1 ACCEPTED SOLUTION

hi  @MauroBote 

Just the adjust the two measure as below:

PLAN AC =
CALCULATE(
SUM(HITOS[PESO]),
USERELATIONSHIP(CALENDARIO[Date],HITOS[FECHA PLAN]),FILTER(
ALLSELECTED(CALENDARIO[Date]),MAX(CALENDARIO[Date])<=MAX(HITOS[FECHA PLAN])&&
ISONORAFTER(CALENDARIO[Date], MAX(CALENDARIO[Date]), DESC)
)
)/HITOS[Total % PESO]

 

REAL AC =
IF(max(CALENDARIO[Date])>today(),"",CALCULATE(
    SUM(HITOS[AVANCE REAL]),
    USERELATIONSHIP(CALENDARIO[Date],HITOS[FECHA REAL 2]),HITOS[FECHA REAL 2]<>BLANK(),FILTER(
        ALLSELECTED(CALENDARIO[Date]),
        ISONORAFTER(CALENDARIO[Date], MAX(CALENDARIO[Date]), DESC)
    )
)/HITOS[Total % PESO])

 

Result:

 

1.JPG

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-lili6-msft
Community Support
Community Support

hi  @MauroBote 

You need to just make some changes in the formula of the two measure.

Please share your sample pbix file for us to have a test, that will be a great help.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hi  @MauroBote 

Just the adjust the two measure as below:

PLAN AC =
CALCULATE(
SUM(HITOS[PESO]),
USERELATIONSHIP(CALENDARIO[Date],HITOS[FECHA PLAN]),FILTER(
ALLSELECTED(CALENDARIO[Date]),MAX(CALENDARIO[Date])<=MAX(HITOS[FECHA PLAN])&&
ISONORAFTER(CALENDARIO[Date], MAX(CALENDARIO[Date]), DESC)
)
)/HITOS[Total % PESO]

 

REAL AC =
IF(max(CALENDARIO[Date])>today(),"",CALCULATE(
    SUM(HITOS[AVANCE REAL]),
    USERELATIONSHIP(CALENDARIO[Date],HITOS[FECHA REAL 2]),HITOS[FECHA REAL 2]<>BLANK(),FILTER(
        ALLSELECTED(CALENDARIO[Date]),
        ISONORAFTER(CALENDARIO[Date], MAX(CALENDARIO[Date]), DESC)
    )
)/HITOS[Total % PESO])

 

Result:

 

1.JPG

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much Lin. You are a genius!!!

amitchandak
Super User
Super User

@MauroBote 

REfer

plan =
var _min = minx(CALENDARIO,CALENDARIO[Date])
return
calculate(sum(HITOS[Plan Value]),filter(CALENDARIO,CALENDARIO[Date]>=_min &&CALENDARIO[Date]<=max(CALENDARIO[Date]))
,userelation(HITOS[Plan Date] , CALENDARIO[Date]))


actual =
var _min = minx(CALENDARIO,CALENDARIO[Date])
return
calculate(sum(HITOS[Real Value]),filter(CALENDARIO,CALENDARIO[Date]>=_min &&CALENDARIO[Date]<=max(CALENDARIO[Date]))
userelation(HITOS[Real Date] , CALENDARIO[Date]))
Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.