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

Table with multilple date relationships

Hi everyone! I'm pretty new in PowerBI, just tarted a few weeks ago.

 

I'm trying to perfom next:

In one table, I have mutiple columns displaying values. Does values are measures or calculated columns, values that come from different sources (Excel, SQL Server). Since all the data is connected I decided to have it all in one table.

So, my scenario is like this: One table that is displaying values by Country. For this table, I need to have 2 date slicers. The idea is that some columns are impacted with one of the slicer and other columns should be impacted with the other slicer. I guest that maybe this could be done changing simple formulas with others a bit more implicit.

Example:

Me actual YTD SALES whas SUM('Sales'[USD])

How I guest that it could work:

CALCULATE(
    SUM('Sales'[USD]);
    DATESBETWEEN(
     'DateTable1'[Date];
     FIRSTDATE('DateTable1'[Date]);
     LASTDATE('DateTable1'[Date])
    )
   )

 

And an other measure that should be impacted with the other slicer using the other DateTable2.

 

But it is not working for me.

Any suggestions? Can something like this be done?

 

Thanks in advance.

1 ACCEPTED SOLUTION
kcantor
Community Champion
Community Champion

@Anonymous

I am a little confused.  Do you actually have two seperate columns with dates or is it one date column with two other columns of data?

If you have multiple date columns, relate both to your date table. One will have an inactive relation ship. To use the first date, just write you dax as usual. To use the second date with the inactive date, use the USERELATIONSHIP function.

For example, I have multiple dates associated with my fact table. One is order date, the other is posting date (there are others too but keeping this simple).

Sales by order date = SUM('FactTable'[LineSales]) -- this measure uses Order Date as I have it set as the main date.

Sales by Posting date = CALCULATE([Sales by order Date], USERELATIONSHIP('FactTable[PostingDate], 'Date'[DateKey])) -- This uses the same calculation referenced in the measure name but switches to use the inactive relationship.

If this is not what you mean, please clarify the request so that we may offer more help. Also, it never hurts to add a snip of the data model and/or relationships or even some sample data as we are not familiar with your particular data.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
kcantor
Community Champion
Community Champion

@Anonymous

I am a little confused.  Do you actually have two seperate columns with dates or is it one date column with two other columns of data?

If you have multiple date columns, relate both to your date table. One will have an inactive relation ship. To use the first date, just write you dax as usual. To use the second date with the inactive date, use the USERELATIONSHIP function.

For example, I have multiple dates associated with my fact table. One is order date, the other is posting date (there are others too but keeping this simple).

Sales by order date = SUM('FactTable'[LineSales]) -- this measure uses Order Date as I have it set as the main date.

Sales by Posting date = CALCULATE([Sales by order Date], USERELATIONSHIP('FactTable[PostingDate], 'Date'[DateKey])) -- This uses the same calculation referenced in the measure name but switches to use the inactive relationship.

If this is not what you mean, please clarify the request so that we may offer more help. Also, it never hurts to add a snip of the data model and/or relationships or even some sample data as we are not familiar with your particular data.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi @kcantor, thanks for your reply.

 

Sorry that maybe my explanation of the case was not clear enough, but anyway your response give me the solution. The USERELATIONSHIP function solve my problem. That, and changing the relationships between tables.

 

Many thanks!

 

Best regards.

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.