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
SebSchoon1
Post Patron
Post Patron

Use of relationship with second calendar Table and running total

Hi guys!

 

With your great help and advices, i have been able to create a nice running total formula.

 

I would like to use it within a second calendar table using USERELATIONSHIP

 

However i'm not able to find how to write it.

 

Here the formula

 
1-RT STOCK OK (début) =
 
VAR _selecteddate = SELECTEDVALUE('Calendrier (début)'[Date])
VAR _datemax = CALCULATE(MAX('Calendrier (début)'[Date]), ALL ('BDD - Lignes de mouvements'))
 
RETURN
    IF(_selecteddate> _datemax,BLANK(),CALCULATE('1-Mesures sur mouvements de stock'[Mouvements de stock],ALL('Calendrier (début)'[Date]),'Calendrier (début)'[Date] <= _selecteddate))

 

 

i would like ti use it with another calendar Table Called  "Calendrier (fin)"

 

any way to do so?

 

Many thanks in advance fellows

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @SebSchoon1 ;

There is no need for a relationship here. A relationship can be established by 'Calendrier (début)'[Date] <= _selecteddate, and the system will recognize the value that matches 'Calendrier (début)'[Date] <= _selecteddate; in a sense It is also a relationship or connection. This is how measures are used, either with relationships or with expressions.


Best Regards,
Community Support Team _ Yalan Wu
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

7 REPLIES 7
v-yalanwu-msft
Community Support
Community Support

Hi, @SebSchoon1 ;

There is no need for a relationship here. A relationship can be established by 'Calendrier (début)'[Date] <= _selecteddate, and the system will recognize the value that matches 'Calendrier (début)'[Date] <= _selecteddate; in a sense It is also a relationship or connection. This is how measures are used, either with relationships or with expressions.


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

v-yalanwu-msft
Community Support
Community Support

Hi, @SebSchoon1 ;

Is your problem solved? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.


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

Hello,

 

Sorry but i have been taken on other actions ^^ not had the time to test it yet 😛

 

I keep you posted!

v-yalanwu-msft
Community Support
Community Support

Hi, @SebSchoon1 ;

Try it.

1-RT STOCK OK (début) =
VAR _selecteddate =
    SELECTEDVALUE ( 'Calendrier (fin)'[Date] )
VAR _datemax =
    CALCULATE (
        MAX ( 'Calendrier (début)'[Date] ),
        ALL ( 'BDD - Lignes de mouvements' )
    )
RETURN
    IF (
        _selecteddate > _datemax,
        BLANK (),
        CALCULATE (
            '1-Mesures sur mouvements de stock'[Mouvements de stock],
            ALL ( 'Calendrier (début)'[Date] ),
            'Calendrier (début)'[Date] <= _selecteddate
        )
    )

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community


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

 

Hi,

 

It worked but i do not understand exactly.

 

How does it work with another calendar with inactive relation and not using the "userelationship"?

 

🙂

amitchandak
Super User
Super User

@SebSchoon1 , Userelationship is for inactive relationship in the same table

 

If you kept inactive relation with the second table it will work but joining with table. But the relation first will not go away

 

example

 

Cumm Sales = CALCULATE(CALCULATE( SUM(Sales[Sales Amount]),userealtionship('Date1'[Date], sales[Date]))

,filter(all('Date1'),'Date1'[date] <=max('Date1'[date])))

Hello @amitchandak 

 

I'm sorry but i have not been able to manage it :s

 

heres what i did but it does not work

1-RT STOCK OK (fin) =

VAR _selecteddate = SELECTEDVALUE('Calendrier (fin)'[Date])
VAR _datemax = CALCULATE(MAX('Calendrier (fin)'[Date]), ALL ('BDD - Lignes de mouvements'))

RETURN
    IF(_selecteddate> _datemax,BLANK(),calculate(CALCULATE('1-Mesures sur mouvements de stock'[Mouvements de stock],USEReLATIONSHIP('Calendrier (fin)'[Date],'BDD - Lignes de mouvements'[DATE PIECE])),ALL('Calendrier (début)'[Date]),'Calendrier (début)'[Date] <= _selecteddate))
 
 
I have well an inactiv relation between movement table and the other calendar table.
 
that's why i would like to keep that formula but to be used with anothet calendar table

 

Helpful resources

Announcements
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.