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
mohammadyousaf
Helper III
Helper III

Comparison between Selected Days and Previous Days

Hi, 

I am using a date slicer to select days to show total count of selected period. However, I want to calculate values beyond selected period for the same days selected in Date Slicer. 

mohammadyousaf_0-1685555160830.png

Basically If I Select 3 days from 27 to 29 May, it should give me the following result in two seperate dax which I will use on card visual:
Current Period = 87 ( 27 to 29 May) 

Previous Period = 98 ( 24 to 26 May) 

I am using the following dax to calcuate current period. 

Current Period =
    CALCULATE(
        DISTINCTCOUNT(tbl_1 [ID_No]),
        DAY(tbl_1[Date] = DAY(TODAY())))

Expected Ouput:

Current Selected Period (days) = [total count]
Previous Period ( days beyond selected days) = [total count] 

Any help is really apprecaited. Thank you. 



1 ACCEPTED SOLUTION

Hi @mohammadyousaf ,

 

According to my test results, the results of Previous Period are displayed normally. Please point out if I misunderstood.

vtangjiemsft_0-1687253170236.png

Best Regards,

Neeko Tang

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

5 REPLIES 5
mohammadyousaf
Helper III
Helper III

Hi @v-tangjie-msft , 

Please see this file. 

Current and Previous Comparison 

 

 

Hi @mohammadyousaf ,

 

According to my test results, the results of Previous Period are displayed normally. Please point out if I misunderstood.

vtangjiemsft_0-1687253170236.png

Best Regards,

Neeko Tang

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

v-tangjie-msft
Community Support
Community Support

Hi @mohammadyousaf ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create measures. 

Current Period =
    CALCULATE(
        DISTINCTCOUNT(tbl_1 [ID_No]),
        DAY(tbl_1[Date] = DAY(TODAY())))
Previous Period = CALCULATE('Table'[Current Period],FILTER(ALL('Table'),'Table'[Date]=MAX('Table'[Date])-3))
Current Selected Period (days) = SUMX(ALLSELECTED('Table'),'Table'[Current Period])
Previous Period ( days beyond selected days) = SUMX(ALLSELECTED('Table'),'Table'[Previous Period])

(3) Then the result is as follows.

vtangjiemsft_0-1685588637342.png

 

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. Thank you.

 

Best Regards,

Neeko Tang

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

Hi @v-tangjie-msft 

Thank you for your response. It seems like I am getting the partial results results, please see below screenshot. 

it is worth to mention that in my table I only have Date & Current period and trying to calculate Previous Period using Dax. 

I have used the Dax as:

Previous Period = CALCULATE([Current Period], FILTER(ALL(Table1), Table1[Date] = MAX(Table1[DATE])-3))
Previuos Selected Period = SUMX(ALLSELECTED(Table1), [Previous Period])

Thank you in advance for your help. 
mohammadyousaf_0-1685605357184.png

 

Hi @mohammadyousaf ,

 

It doesn't seem to be a problem in my example file.

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. Thank you.

 

Best Regards,

Neeko Tang

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.