简体   繁体   中英

Calculating the difference between two filters in Power BI

I have an Excel sheet with data in the following format

 UploadDate Grant Family Project Officer 05/04/2019 00J90301 AA 05/04/2019 01J32201 AA 05/04/2019 97891601 AA 05/04/2019 00406918 AB 05/04/2019 00406015 AC 05/04/2019 00406515 AC 05/04/2019 00406715 AC 05/04/2019 00406815 AC 05/04/2019 00526416 AC 05/04/2019 00571110 AC 05/04/2019 00D28115 AC 05/04/2019 00D28215 AC 05/04/2019 00D28315 AC 05/04/2019 00D28415 AC 05/04/2019 00D29215 AC 05/04/2019 00D29515 AC 05/04/2019 00D30415 AC 05/04/2019 00D30715 AC 05/04/2019 00D30815 AC 05/04/2019 00D31015 AC 05/04/2019 00D41515 AC 05/04/2019 00D49516 AC 05/04/2019 00D63217 AC 05/04/2019 00D63317 AC 05/04/2019 00E01521 AC 05/04/2019 00E01547 AC 05/04/2019 00E01999 AC 05/04/2019 00E02038 AC 05/04/2019 00E02335 AC 05/04/2019 00E02338 AC 05/04/2019 00E16405 AC 05/04/2019 00E66504 AC 05/04/2019 00E66603 AC 05/04/2019 00E66604 AC 05/04/2019 02E01503 AC 05/04/2019 83579302 AC 05/04/2019 95490317 AC 05/04/2019 97431017 AC 05/04/2019 98408917 AC 05/04/2019 98409217 AC 05/04/2019 98485117 AC 05/04/2019 98490416 AC 05/04/2019 99060104 AC 05/04/2019 99407714 AC 05/04/2019 99446514 AC 05/04/2019 00T26201 AD 05/04/2019 00T76718 AD 05/04/2019 00T77117 AD 06/11/2019 00J90301 AA 06/11/2019 01J32201 AA 06/11/2019 97891601 AA 06/11/2019 00406918 AB 06/11/2019 00406015 AC 06/11/2019 00406515 AC 06/11/2019 00406715 AC 06/11/2019 00406815 AC 06/11/2019 00526416 AC 06/11/2019 00571110 AC 06/11/2019 00D28115 AC 06/11/2019 00D28215 AC 06/11/2019 00D28315 AC 06/11/2019 00D28415 AC 06/11/2019 00D29215 AC 06/11/2019 00D29515 AC 06/11/2019 00D30415 AC 06/11/2019 00D30715 AC 06/11/2019 00D30815 AC 06/11/2019 00D31015 AC 06/11/2019 00D41515 AC 06/11/2019 00D49516 AC 06/11/2019 00D63217 AC 06/11/2019 00D63317 AC 06/11/2019 00E01521 AC 06/11/2019 00E01547 AC 06/11/2019 00E01999 AC 06/11/2019 00E02038 AC 06/11/2019 00E02335 AC 06/11/2019 00E02338 AC 06/11/2019 00E16405 AC 06/11/2019 00E66504 AC 06/11/2019 00E66603 AC 06/11/2019 00E66604 AC 06/11/2019 02E01503 AC 06/11/2019 83579302 AC 06/11/2019 95490317 AC 06/11/2019 97431017 AC 06/11/2019 98408917 AC 06/11/2019 98409217 AC 06/11/2019 98485117 AC 06/11/2019 98490416 AC 06/11/2019 99060104 AC 06/11/2019 99407714 AC 06/11/2019 99446514 AC 06/11/2019 00T26201 AC 06/11/2019 00T76718 AC 06/11/2019 00T77117 AC

And our PowerBI file has a few tables that return how many Project Officers have worked on between 1-2 grant families, between 3-9, and more than 20, for a certain upload date. We've checked those figures and filters and they work.

Our next goal is to present the difference between the upload dates.

I created a DAX Measure like

 PO_Difference = Calculate(DistinctCount('Report'[Project Officer]),'Report'[Upload Date] = date (2019,11,6))-Calculate(DistinctCount('Report'[Project Officer]),'Report'[Upload Date] = date (2019,4,5)) '

And it's not returning our expected result. If I break the formula into two, both calculate portions return the expected result if I apply their relevant filter, but my hunch is the filters are distorting what the formula returns for each section, and I'm at a loss how else to approach this. Any help would be gratefully received.

Can you try using variables?

PO_Difference =
VAR x = Calculate(DistinctCount('Report'[Project Officer]),'Report'[Upload Date] = date (2019,11,6))

VAR y = Calculate(DistinctCount('Report'[Project Officer]),'Report'[Upload Date] = date (2019,4,5))

return x -y

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM