Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
saivina2920
Post Prodigy
Post Prodigy

count data mismatching in Table Chart

I am getting some wrong count in the chart table. Example, i have given the below. 

 

sample Test File and data Link : https://1drv.ms/u/s!AiSRcgO5FUmN8USBS75RKolqBQDT?e=HBxCu6 

 

saivina2920_0-1628863386473.png

What is the problem.?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @saivina2920 ,

Please update the formula of measure [TempBalCount] as below and check whether it can get your expected result.... You can find the attachment for the details. 

TempBalCount =
VAR _selreldate =
SELECTEDVALUE ( EMP_TABLE[EMP_RESIGN_DATE] )
RETURN
IF (
ISFILTERED ( 'EMP_TABLE'[EMP_STATE] ),
IF (
[XTOY] = [YTOX],
BLANK (),
IF ( _selreldate > [vToday], 0, [XTOY] - [YTOX] )
),
BLANK ()
)

yingyinr_0-1629266282395.png

Also, it is worth noting that if you want to implement this "dynamic" feature it is not appropriate to get the duration days by creating a calculated column [DurDays]. So you have to use the measure [Duration days] instead of the calculated column [DurDays]. For more information about the difference between calculated columns and measure, you can read the following blogs.

Calculated Columns and Measures in DAX

Calculated Columns vs Measures

Best Regards

View solution in original post

14 REPLIES 14
Greg_Deckler
Super User
Super User

@saivina2920 This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks for your help.

 

When you are look at my Test pbix file, it's showing more emp_no record. also, the future date count should not come.

can you pls. check the file and give us th correct count please..?

Anonymous
Not applicable

Hi @saivina2920 ,

I updated your sample pbix file(see attachment), please check whether that is what you want.

Measure = 
VAR _selemp =
    SELECTEDVALUE ( 'EMP_TABLE'[EMP_NO] )
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'EMP_TABLE'[EMP_STATUS] ),
        FILTER ( ALLSELECTED ( 'EMP_TABLE' ), 'EMP_TABLE'[EMP_NO] = _selemp )
    )
VAR _selreldate =
    SELECTEDVALUE ( EMP_TABLE[EMP_RELIEVE_DATE] )
RETURN
    IF (
        _selreldate > [vToday]
            || _count > 1,
        BLANK (),
        DATEDIFF ( SELECTEDVALUE ( EMP_TABLE[EMP_RESIGN_DATE] ), TODAY (), DAY )
    )

yingyinr_0-1629109480339.png

Best Regards

Thanks for your quick reply. I modified as per my requirement.

 

Output coming perfect except few points which is highlighted below.

 

pls. find the latest test file with data in the following link.

 

https://1drv.ms/u/s!AiSRcgO5FUmN8UiVPTOFR_R4KHIl?e=az7Elh 

 

Output coming perfect except few points which is highlighted below.

 

saivina2920_1-1629116956932.png

 

kindly let me know if you need any more details.

 

 

Anonymous
Not applicable

Hi @saivina2920 ,

I have updated your sample pbix file(see attachment), please check whether it can get the correct result.

Update the formula of calculated column [DurDays] as below

DurDays = 
IF (
    EMP_TABLE[EMP_RESIGN_DATE] > [vToday]
        || CALCULATE (
            [BalCount],
            ALLEXCEPT ( 'EMP_TABLE', 'EMP_TABLE'[EMP_NO], 'EMP_TABLE'[EMP_RESIGN_DATE] )
        ) = 0,
    BLANK (),
    DATEDIFF ( EMP_TABLE[EMP_RESIGN_DATE], TODAY (), DAY )
)

Or you can create the below 2 measures to get it:

Measure = 
VAR _selreldate =
    SELECTEDVALUE ( EMP_TABLE[EMP_RESIGN_DATE] )
RETURN
    IF (
        _selreldate > [vToday]
            || [BalCount] =0,
        BLANK (),
        DATEDIFF ( _selreldate, TODAY (), DAY )
    )
Duration days = SUMX(GROUPBY('EMP_TABLE','EMP_TABLE'[EMP_NO],'EMP_TABLE'[EMP_RESIGN_DATE]),[Measure])

yingyinr_0-1629167057891.png

Best Regards

Hi @Anonymous ,

 

Still the count is not accurate. pls. refer the below screenshot for clear reference.

 

saivina2920_0-1629168777195.png

 

Anonymous
Not applicable

Hi @saivina2920 ,

Please create another measure as below to get Balcount to exclude the future dates:

TempBalCount = 
VAR _selreldate =
    SELECTEDVALUE ( EMP_TABLE[EMP_RESIGN_DATE] )
RETURN
    IF ( _selreldate > [vToday], 0, [XTOY] - [YTOX] )

Then update the formula of measure [BalCount] as below:

BalCount = SUMX(GROUPBY('EMP_TABLE','EMP_TABLE'[EMP_NO],'EMP_TABLE'[EMP_RESIGN_DATE]),[TempBalCount])

yingyinr_0-1629170348386.png

Best Regards

Thanks for your quick reply. Everyting is perfect except one.

 

We want to display only two records and remaining want to exclude.

 

Because, A-8 = C (c count rows only two records. that's why)

 

pls. refer the below screenshot.

 

saivina2920_0-1629173751801.png

 

Anonymous
Not applicable

Hi @saivina2920 ,

Please update the formula of measure [TempBalCount] as below:

TempBalCount =
VAR _selreldate =
SELECTEDVALUE ( EMP_TABLE[EMP_RESIGN_DATE] )
RETURN
IF (
[XTOY] - [YTOX] = 0,
BLANK (),
IF ( _selreldate > [vToday], 0, [XTOY] - [YTOX] )
)

yingyinr_2-1629177477813.png

Best Regards

awesome results.

In the below screenshot, when user selects "EMP_STATE" then only it should show the records in the table. otherwise no need to display records in the table.

How to apply this logic..?

saivina2920_0-1629193678860.png

 

If this works, then mine is over.

 

Anonymous
Not applicable

Hi @saivina2920 ,

Please update the formula of measure [TempBalCount] as below and check whether it can get your expected result.... You can find the attachment for the details. 

TempBalCount =
VAR _selreldate =
SELECTEDVALUE ( EMP_TABLE[EMP_RESIGN_DATE] )
RETURN
IF (
ISFILTERED ( 'EMP_TABLE'[EMP_STATE] ),
IF (
[XTOY] = [YTOX],
BLANK (),
IF ( _selreldate > [vToday], 0, [XTOY] - [YTOX] )
),
BLANK ()
)

yingyinr_0-1629266282395.png

Also, it is worth noting that if you want to implement this "dynamic" feature it is not appropriate to get the duration days by creating a calculated column [DurDays]. So you have to use the measure [Duration days] instead of the calculated column [DurDays]. For more information about the difference between calculated columns and measure, you can read the following blogs.

Calculated Columns and Measures in DAX

Calculated Columns vs Measures

Best Regards

It's Awesome and it's fantastic logic with favourable reply.

 

Hi @Anonymous ,

Can you pls. give us the idea to remove the unneccessary records from the list. (pls. refer the screenshot in the highlighted cell).

 

thanks for your spending golden time.

pls. tell us, how to remove the highligted unmatching data's..

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.