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
fabo
Advocate III
Advocate III

Show selected date and the dates before it

Hello everyone.

 

I’m trying to solve this problem. I have a Date Table and a Sales Table, both related by a key.

 

date_table.png          sales_table.png

 

model.png 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I need a line chart that shows data from January (the earliest date) to the selected date in a slicer.

 

The closest I got was deactivating interactions between the slicer and the line chart, but obviously the latter doesn’t respond to the selected date in the slicer.  If I keep the interaction, it just shows a dot.

 

visuals.png

 

How could I get this solved using DAX?

 

 

2 ACCEPTED SOLUTIONS
v-chuncz-msft
Community Support
Community Support

@fabo,

 

You may try adding CROSSFILTER Function in an appropriate measure and set cross-filter direction to None.

Community Support Team _ Sam Zha
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

Hi @v-chuncz-msft,

 

You gave me a nice idea.  I don't know if it's the more efficient idea but it works for me.

 

I made a copy of the Date Table just for being used in the line chart:

 

 

Date for visual = 'Date'

 

 

Then I made a measure to capture the current selection of the original Date Table:

 

 

Selection = CALCULATE(SUM('Date'[Date]))

I used that selection as a part of an argument to evaluate if the new dates are older or equal to it.  In the CALCULATE function I deactivated the cross filter between original dates and fact table dates with the function CROSSFILTER:

 

 

Sales by Month = 
    CALCULATE(
        SUM(Sales[Sales]);
        CROSSFILTER(
            'Date'[date_key];
            Sales[date_key];
            None
        );
        FILTER(
            'Date for visual';
            'Date for visual'[Date] <= [Selection]
        )
    )

Finally I added the new date table in the visual field, and I works just fine.

 

Captura.PNG

 

 

The file is here.

 

Thank you for your support!

 

Best regards,

 

fabo

 

 

View solution in original post

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@fabo,

 

You may try adding CROSSFILTER Function in an appropriate measure and set cross-filter direction to None.

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

Hi @v-chuncz-msft,

 

You gave me a nice idea.  I don't know if it's the more efficient idea but it works for me.

 

I made a copy of the Date Table just for being used in the line chart:

 

 

Date for visual = 'Date'

 

 

Then I made a measure to capture the current selection of the original Date Table:

 

 

Selection = CALCULATE(SUM('Date'[Date]))

I used that selection as a part of an argument to evaluate if the new dates are older or equal to it.  In the CALCULATE function I deactivated the cross filter between original dates and fact table dates with the function CROSSFILTER:

 

 

Sales by Month = 
    CALCULATE(
        SUM(Sales[Sales]);
        CROSSFILTER(
            'Date'[date_key];
            Sales[date_key];
            None
        );
        FILTER(
            'Date for visual';
            'Date for visual'[Date] <= [Selection]
        )
    )

Finally I added the new date table in the visual field, and I works just fine.

 

Captura.PNG

 

 

The file is here.

 

Thank you for your support!

 

Best regards,

 

fabo

 

 

Anonymous
Not applicable

 I have a similar problem to this but I am using a data table to display all values, and is not working for me. Could you please help?

 

https://community.powerbi.com/t5/Desktop/Data-table-to-display-preceding-data-based-on-date-slicer/m...

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.